CallerData   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 25
c 2
b 0
f 0
dl 0
loc 96
ccs 26
cts 26
cp 1
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getArgs() 0 3 1
A extractDataFrom() 0 5 2
A parse() 0 9 1
A getClass() 0 3 1
A getFile() 0 3 1
A getType() 0 3 1
A getObject() 0 3 1
A getLine() 0 3 1
A getFunction() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Accessories\Caller;
4
5
use AlecRabbit\Accessories\Caller;
6
use AlecRabbit\Accessories\Caller\Contracts\CallerDataInterface;
7
use AlecRabbit\Reports\Core\AbstractReport;
8
use AlecRabbit\Reports\Core\AbstractReportable;
9
10
/**
11
 * Class CallerData
12
 * @psalm-suppress PropertyNotSetInConstructor
13
 */
14
class CallerData extends AbstractReport implements CallerDataInterface
15
{
16
    /** @var string */
17
    protected $function;
18
19
    /** @var int|null */
20
    protected $line;
21
22
    /** @var string|null */
23
    protected $file;
24
25
    /** @var string|null */
26
    protected $class;
27
28
    /** @var object|null */
29
    protected $object;
30
31
    /** @var string|null */
32
    protected $type;
33
34
    /** @var array|null */
35
    protected $args;
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 7
    public function getFunction(): string
41
    {
42 7
        return $this->function;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 5
    public function getLine(): ?int
49
    {
50 5
        return $this->line;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 5
    public function getFile(): ?string
57
    {
58 5
        return $this->file;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 7
    public function getClass(): ?string
65
    {
66 7
        return $this->class;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 3
    public function getObject(): ?object
73
    {
74 3
        return $this->object;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 5
    public function getType(): ?string
81
    {
82 5
        return $this->type;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 3
    public function getArgs(): ?array
89
    {
90 3
        return $this->args;
91
    }
92
93 8
    protected function extractDataFrom(AbstractReportable $reportable = null): void
94
    {
95 8
        parent::extractDataFrom($reportable);
96 8
        if ($reportable instanceof Caller) {
97 8
            $this->parse($reportable->getData());
98
        }
99 8
    }
100
101 8
    protected function parse(array $caller): void
102
    {
103
        $this->function = $caller[self::FUNCTION];
104 8
        $this->line = $caller[self::LINE] ?? null;
105 8
        $this->file = $caller[self::FILE] ?? null;
106 8
        $this->class = $caller[self::CLS] ?? null;
107 8
        $this->object = $caller[self::OBJECT] ?? null;
108 8
        $this->type = $caller[self::TYPE] ?? null;
109 8
        $this->args = $caller[self::ARGS] ?? null;
110 8
    }
111
}
112