Primo Committ
This commit is contained in:
42
vendor/facade/flare-client-php/src/Glows/Glow.php
vendored
Normal file
42
vendor/facade/flare-client-php/src/Glows/Glow.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Facade\FlareClient\Glows;
|
||||
|
||||
use Facade\FlareClient\Concerns\UsesTime;
|
||||
use Facade\FlareClient\Enums\MessageLevels;
|
||||
|
||||
class Glow
|
||||
{
|
||||
use UsesTime;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var array */
|
||||
private $metaData;
|
||||
|
||||
/** @var string */
|
||||
private $messageLevel;
|
||||
|
||||
/** @var float */
|
||||
private $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);
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'time' => $this->getCurrentTime(),
|
||||
'name' => $this->name,
|
||||
'message_level' => $this->messageLevel,
|
||||
'meta_data' => $this->metaData,
|
||||
'microtime' => $this->microtime,
|
||||
];
|
||||
}
|
||||
}
|
||||
27
vendor/facade/flare-client-php/src/Glows/Recorder.php
vendored
Normal file
27
vendor/facade/flare-client-php/src/Glows/Recorder.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Facade\FlareClient\Glows;
|
||||
|
||||
class Recorder
|
||||
{
|
||||
public const GLOW_LIMIT = 30;
|
||||
|
||||
private $glows = [];
|
||||
|
||||
public function record(Glow $glow)
|
||||
{
|
||||
$this->glows[] = $glow;
|
||||
|
||||
$this->glows = array_slice($this->glows, static::GLOW_LIMIT * -1, static::GLOW_LIMIT);
|
||||
}
|
||||
|
||||
public function glows(): array
|
||||
{
|
||||
return $this->glows;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->glows = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user