Glow::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Facade\FlareClient\Glows;
4
5
use Facade\FlareClient\Concerns\UsesTime;
6
use Facade\FlareClient\Enums\MessageLevels;
7
8
class Glow
9
{
10
    use UsesTime;
11
12
    /** @var string */
13
    private $name;
14
15
    /** @var array */
16
    private $metaData;
17
18
    /** @var string */
19
    private $messageLevel;
20
21
    /** @var float */
22
    private $microtime;
23
24
    public function __construct(string $name, string $messageLevel = MessageLevels::INFO, array $metaData = [], ?float $microtime = null)
25
    {
26
        $this->name = $name;
27
        $this->messageLevel = $messageLevel;
28
        $this->metaData = $metaData;
29
        $this->microtime = $microtime ?? microtime(true);
30
    }
31
32
    public function toArray()
33
    {
34
        return [
35
            'time' => $this->getCurrentTime(),
36
            'name' => $this->name,
37
            'message_level' => $this->messageLevel,
38
            'meta_data' => $this->metaData,
39
            'microtime' => $this->microtime,
40
        ];
41
    }
42
}
43