﻿GlowRecorder.php                                                                                    0000644                 00000001026 00000000000 0007613 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?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 = [];
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Glow.php                                                                                            0000644                 00000002363 00000000000 0006132 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?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,
        ];
    }
}
                                                                                                                                                                                                                                                                             Recorder.php                                                                                        0000775                 00000000700 00000000000 0006765 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?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 = [];
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             