Total Complexity | 7 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | final class ClassMethodReference |
||
14 | { |
||
15 | /** @var string */ |
||
16 | private $name; |
||
17 | |||
18 | /** @var string */ |
||
19 | private $className; |
||
20 | |||
21 | /** @var string */ |
||
22 | private $methodName; |
||
23 | |||
24 | 13 | public function __construct(string $name) |
|
25 | { |
||
26 | 13 | if ($name === '') { |
|
27 | 1 | throw new InvalidArgumentException( |
|
28 | 1 | 'Invalid ClassMethodReference, empty string given. Format must be ClassName::methodName.' |
|
29 | ); |
||
30 | } |
||
31 | |||
32 | 12 | $this->name = $name; |
|
33 | |||
34 | 12 | $e = explode('::', $this->name); |
|
35 | |||
36 | 12 | if (count($e) < 2) { |
|
37 | 1 | throw new InvalidArgumentException( |
|
38 | 1 | sprintf('Invalid ClassMethodReference, "%s" given. Format must be ClassName::methodName.', $name) |
|
39 | ); |
||
40 | } |
||
41 | |||
42 | 11 | [$this->className, $this->methodName] = $e; |
|
43 | |||
44 | 11 | $this->methodName = trim($this->methodName); |
|
45 | |||
46 | 11 | if ($this->methodName === '') { |
|
47 | 2 | throw new InvalidArgumentException( |
|
48 | 2 | sprintf('You must specify a method name to find. "%s" given.', $name) |
|
49 | ); |
||
50 | } |
||
51 | 9 | } |
|
52 | |||
53 | 7 | public function getName() : string |
|
54 | { |
||
55 | 7 | return $this->name; |
|
56 | } |
||
57 | |||
58 | 7 | public function getClassName() : string |
|
59 | { |
||
60 | 7 | return $this->className; |
|
61 | } |
||
62 | |||
63 | 7 | public function getMethodName() : string |
|
66 | } |
||
67 | } |
||
68 |