ok

Mini Shell

Direktori : /home2/selectio/www/3-idiots/vendor/facade/flare-client-php/src/Truncation/
Upload File :
Current File : //home2/selectio/www/3-idiots/vendor/facade/flare-client-php/src/Truncation/ReportTrimmer.php

<?php

namespace Facade\FlareClient\Truncation;

class ReportTrimmer
{
    protected static $maxPayloadSize = 524288;

    protected $strategies = [
        TrimStringsStrategy::class,
        TrimContextItemsStrategy::class,
    ];

    public function trim(array $payload): array
    {
        foreach ($this->strategies as $strategy) {
            if (! $this->needsToBeTrimmed($payload)) {
                break;
            }

            $payload = (new $strategy($this))->execute($payload);
        }

        return $payload;
    }

    public function needsToBeTrimmed(array $payload): bool
    {
        return strlen(json_encode($payload)) > self::getMaxPayloadSize();
    }

    public static function getMaxPayloadSize(): int
    {
        return self::$maxPayloadSize;
    }

    public static function setMaxPayloadSize(int $maxPayloadSize): void
    {
        self::$maxPayloadSize = $maxPayloadSize;
    }
}

Zerion Mini Shell 1.0