Total Complexity | 4 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class TimesCalled implements Indifferent |
||
12 | { |
||
13 | /** |
||
14 | * Original object. |
||
15 | * |
||
16 | * @var T |
||
17 | */ |
||
18 | private object $origin; |
||
19 | |||
20 | /** |
||
21 | * Method to pay attention to. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | private string $method; |
||
26 | |||
27 | /** |
||
28 | * How many times the method was called. |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | private int $times = 0; |
||
33 | |||
34 | /** |
||
35 | * Ctor. |
||
36 | * |
||
37 | * @param T $origin |
||
38 | * @param string $method |
||
39 | */ |
||
40 | public function __construct(object $origin, string $method) |
||
41 | { |
||
42 | $this->origin = $origin; |
||
43 | $this->method = $method; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Returns the number of calls to the specified method. |
||
48 | * |
||
49 | * @return int |
||
50 | */ |
||
51 | public function value(): int |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Sends calls through itself and counts how many times a specific method was called. |
||
58 | * {@inheritDoc} |
||
59 | */ |
||
60 | public function __call(string $name, array $arguments): mixed |
||
66 | } |
||
67 | } |
||
68 |