Total Complexity | 10 |
Total Lines | 99 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
20 | class BenchmarkFunction |
||
21 | { |
||
22 | use GettableName; |
||
23 | |||
24 | /** @var null|string */ |
||
25 | private $comment; |
||
26 | |||
27 | /** @var int */ |
||
28 | private $index; |
||
29 | |||
30 | /** @var array */ |
||
31 | private $args; |
||
32 | |||
33 | /** @var callable */ |
||
34 | private $func; |
||
35 | |||
36 | /** @var mixed */ |
||
37 | private $result; |
||
38 | |||
39 | /** |
||
40 | * BenchmarkedFunction constructor. |
||
41 | * @param callable $func |
||
42 | * @param string $name |
||
43 | * @param int $index |
||
44 | * @param array $args |
||
45 | * @param null|string $comment |
||
46 | */ |
||
47 | 2 | public function __construct($func, string $name, int $index, array $args, ?string $comment = null) |
|
48 | { |
||
49 | 2 | $this->func = $func; |
|
50 | 2 | $this->comment = $comment; |
|
51 | 2 | $this->name = $name; |
|
52 | 2 | $this->index = $index; |
|
53 | 2 | $this->args = $args; |
|
54 | 2 | } |
|
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | 2 | public function getComment(): string |
|
60 | { |
||
61 | 2 | return $this->comment ? str_decorate($this->comment, '"') : ''; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return int |
||
66 | */ |
||
67 | 2 | public function getIndex(): int |
|
68 | { |
||
69 | 2 | return $this->index; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | 2 | public function getArgs(): array |
|
76 | { |
||
77 | 2 | return $this->args; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return callable |
||
82 | */ |
||
83 | 2 | public function getFunction(): callable |
|
84 | { |
||
85 | 2 | return $this->func; |
|
86 | } |
||
87 | |||
88 | 2 | public function getEnumeratedName(): string |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return mixed |
||
96 | */ |
||
97 | 1 | public function getResult() |
|
98 | { |
||
99 | 1 | return $this->result; |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * @param mixed $result |
||
104 | */ |
||
105 | 2 | public function setResult($result): void |
|
106 | { |
||
107 | 2 | $this->result = $result; |
|
108 | 2 | } |
|
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 2 | public function getIndexedName(): string |
|
119 | ); |
||
120 | } |
||
121 | } |
||
122 |