<commit_before><?php

declare(strict_types=1);
/**
 * This file is part of the BEAR.Sunday package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace BEAR\Sunday\Provide\Error;

use BEAR\Resource\Code;
use BEAR\Resource\Exception\BadRequestException as BadRequest;
use BEAR\Resource\Exception\ResourceNotFoundException as NotFound;
use BEAR\Resource\Exception\ServerErrorException as ServerError;
use BEAR\Sunday\Extension\Error\ErrorInterface;
use BEAR\Sunday\Extension\Router\RouterMatch as Request;
use BEAR\Sunday\Extension\Transfer\TransferInterface;

/**
 * Vnd.Error media type error
 *
 * @see https://github.com/blongden/vnd.error
 */
final class VndError implements ErrorInterface
{
    /**
     * @var string
     */
    const CONTENT_TYPE = 'application/vnd.error+json';

    /**
     * @var TransferInterface
     */
    private $transfer;

    /**
     * @var ErrorPage
     */
    private $errorPage;

    public function __construct(TransferInterface $transfer)
    {
        $this->transfer = $transfer;
        $this->errorPage = new ErrorPage;
    }

    /**
     * {@inheritdoc}
     */
    public function handle(\Exception $e, Request $request)
    {
        if ($this->isCodeExists($e)) {
            $this->errorPage->code = $e->getCode();
            $this->errorPage->body = ['message' => (new Code)->statusText[$this->errorPage->code]];

            return $this;
        }
        $this->errorPage->code = 500;
        $this->errorPage->body = ['message' => '500 Server Error'];
        error_log($request);
        error_log($e);

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function transfer()
    {
        $this->errorPage->headers['content-type'] = self::CONTENT_TYPE;
        $this->transfer->__invoke($this->errorPage, []);
    }

    private function isCodeExists(\Exception $e) : bool
    {
        if (! ($e instanceof NotFound || $e instanceof BadRequest || $e instanceof ServerError)) {
            return false;
        }

        return array_key_exists($e->getCode(), (new Code)->statusText);
    }
}
<commit_msg>cast string not to fall the strict test<commit_after><?php

declare(strict_types=1);
/**
 * This file is part of the BEAR.Sunday package.
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace BEAR\Sunday\Provide\Error;

use BEAR\Resource\Code;
use BEAR\Resource\Exception\BadRequestException as BadRequest;
use BEAR\Resource\Exception\ResourceNotFoundException as NotFound;
use BEAR\Resource\Exception\ServerErrorException as ServerError;
use BEAR\Sunday\Extension\Error\ErrorInterface;
use BEAR\Sunday\Extension\Router\RouterMatch as Request;
use BEAR\Sunday\Extension\Transfer\TransferInterface;

/**
 * Vnd.Error media type error
 *
 * @see https://github.com/blongden/vnd.error
 */
final class VndError implements ErrorInterface
{
    /**
     * @var string
     */
    const CONTENT_TYPE = 'application/vnd.error+json';

    /**
     * @var TransferInterface
     */
    private $transfer;

    /**
     * @var ErrorPage
     */
    private $errorPage;

    public function __construct(TransferInterface $transfer)
    {
        $this->transfer = $transfer;
        $this->errorPage = new ErrorPage;
    }

    /**
     * {@inheritdoc}
     */
    public function handle(\Exception $e, Request $request)
    {
        if ($this->isCodeExists($e)) {
            $this->errorPage->code = $e->getCode();
            $this->errorPage->body = ['message' => (new Code)->statusText[$this->errorPage->code]];

            return $this;
        }
        $this->errorPage->code = 500;
        $this->errorPage->body = ['message' => '500 Server Error'];
        error_log((string) $request);
        error_log((string) $e);

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function transfer()
    {
        $this->errorPage->headers['content-type'] = self::CONTENT_TYPE;
        $this->transfer->__invoke($this->errorPage, []);
    }

    private function isCodeExists(\Exception $e) : bool
    {
        if (! ($e instanceof NotFound || $e instanceof BadRequest || $e instanceof ServerError)) {
            return false;
        }

        return array_key_exists($e->getCode(), (new Code)->statusText);
    }
}

{'fraction_non_alphanumeric': 0.14185063410051668, 'fraction_numerical': 0.0032879286049788633, 'mean_word_length': 2.697048611111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 2, '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': '946786', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1237, 'n_words': 261}