<?php

// namespace Flugg\Responder\Http\Responses\Decorators;

namespace App\Response;

use Flugg\Responder\Http\Responses\Decorators\ResponseDecorator;
use Illuminate\Http\JsonResponse;

/**
 * A decorator class for adding a success flag to the response data.
 *
 * @author  Alexander Tømmerås <flugged@gmail.com>
 * @license The MIT License
 */
class ApiProcessedTimeDecorator extends ResponseDecorator
{
    /**
     * Generate a JSON response.
     */
    public function make(array $data, int $status, array $headers = []): JsonResponse
    {
        if (isset($headers['processedTime'])) {

            return $this->factory->make(array_merge([
                'processedTime' => $headers['processedTime'],
            ], $data), $status, $headers);
        }

        return $this->factory->make($data, $status, $headers);
    }
}
