| Server IP : 3.138.164.131 / Your IP : 216.73.216.136 Web Server : Apache System : Linux ns1.techtime.me 4.18.0-147.8.1.el8.lve.1.x86_64 #1 SMP Mon Jun 29 09:55:57 EDT 2020 x86_64 User : injazaat ( 1471) PHP Version : 8.1.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/injazaat/public_html/vendor/spatie/flare-client-php/src/Truncation/ |
Upload File : |
<?php
namespace Spatie\FlareClient\Truncation;
class TrimStringsStrategy extends AbstractTruncationStrategy
{
/**
* @return array<int, int>
*/
public static function thresholds(): array
{
return [1024, 512, 256];
}
/**
* @param array<int|string, mixed> $payload
*
* @return array<int|string, mixed>
*/
public function execute(array $payload): array
{
foreach (static::thresholds() as $threshold) {
if (! $this->reportTrimmer->needsToBeTrimmed($payload)) {
break;
}
$payload = $this->trimPayloadString($payload, $threshold);
}
return $payload;
}
/**
* @param array<int|string, mixed> $payload
* @param int $threshold
*
* @return array<int|string, mixed>
*/
protected function trimPayloadString(array $payload, int $threshold): array
{
array_walk_recursive($payload, function (&$value) use ($threshold) {
if (is_string($value) && strlen($value) > $threshold) {
$value = substr($value, 0, $threshold);
}
});
return $payload;
}
}