<commit_before><?php

namespace Detail\Blitline\Response;

use GuzzleHttp\Command\Guzzle\Operation;
use GuzzleHttp\Psr7\Response as PsrResponse;

use Detail\Blitline\Response\Resource as ClientResource;
use Detail\Blitline\Exception;

class ResourceResponse extends BaseResponse
{
    /**
     * @var ClientResource
     */
    protected $resource;

    /**
     * @param Operation $operation
     * @param PsrResponse $response
     * @return ResourceResponse
     */
    public static function fromOperation(Operation $operation, PsrResponse $response): Response
    {
        return new static($response);
    }

    public function getResource(): ClientResource
    {
        if ($this->resource === null) {
            $this->resource = new ClientResource($this->getData());
        }

        return $this->resource;
    }

    /**
     * @param string $key
     * @return mixed|null<commit_msg>Added fromData method<commit_after><?php

namespace Detail\Blitline\Response;

use GuzzleHttp\Command\Guzzle\Operation;
use GuzzleHttp\Psr7\Response as PsrResponse;

use Detail\Blitline\Response\Resource as ClientResource;
use Detail\Blitline\Exception;

class ResourceResponse extends BaseResponse
{
    /**
     * @var ClientResource
     */
    protected $resource;

    /**
     * @param array $data
     * @return ResourceResponse
     */
    public static function fromData(array $data)
    {
        $response = new PsrResponse(200, [], json_encode($data));

        return new static($response);
    }
    
    /**
     * @param Operation $operation
     * @param PsrResponse $response
     * @return ResourceResponse
     */
    public static function fromOperation(Operation $operation, PsrResponse $response): Response
    {
        return new static($response);
    }

    public function getResource(): ClientResource
    {
        if ($this->resource === null) {
            $this->resource = new ClientResource($this->getData());
        }

        return $this->resource;
    }

    /**
     * @param string $key
     * @return mixed|null
{'fraction_non_alphanumeric': 0.10948905109489052, 'fraction_numerical': 0.0024330900243309003, 'mean_word_length': 2.7724770642201837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '344419', 'n_tokens_mistral': 575, 'n_tokens_neox': 561, 'n_words': 136}