Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace Spatie\FlareClient\Glows;
use Spatie\FlareClient\Concerns\UsesTime;
use Spatie\FlareClient\Enums\MessageLevels;
class Glow
{
use UsesTime;
protected string $name;
/** @var array<int, mixed> */
protected array $metaData = [];
protected string $messageLevel;
protected float $microtime;
/**
* @param string $name
* @param string $messageLevel
* @param array<int, mixed> $metaData
* @param float|null $microtime
*/
public function __construct(
string $name,
string $messageLevel = MessageLevels::INFO,
array $metaData = [],
?float $microtime = null
) {
$this->name = $name;
$this->messageLevel = $messageLevel;
$this->metaData = $metaData;
$this->microtime = $microtime ?? microtime(true);
}
/**
* @return array{time: int, name: string, message_level: string, meta_data: array, microtime: float}
*/
public function toArray(): array
{
return [
'time' => $this->getCurrentTime(),
'name' => $this->name,
'message_level' => $this->messageLevel,
'meta_data' => $this->metaData,
'microtime' => $this->microtime,
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Spatie\FlareClient\Glows;
class GlowRecorder
{
const GLOW_LIMIT = 30;
/** @var array<int, Glow> */
protected array $glows = [];
public function record(Glow $glow): void
{
$this->glows[] = $glow;
$this->glows = array_slice($this->glows, static::GLOW_LIMIT * -1, static::GLOW_LIMIT);
}
/** @return array<int, Glow> */
public function glows(): array
{
return $this->glows;
}
public function reset(): void
{
$this->glows = [];
}
}