Total Complexity | 5 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class Instantiator |
||
10 | { |
||
11 | /** |
||
12 | * Returns new instance of a rule by the given class name. |
||
13 | * |
||
14 | * @param string $class |
||
15 | * |
||
16 | * @return object|RuleInterface |
||
17 | * @throws UnexpectedValueException |
||
18 | * @throws ReflectionException |
||
19 | */ |
||
20 | public function make($class) |
||
21 | { |
||
22 | return $this->reflect($class)->newInstanceWithoutConstructor(); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Returns new instance of a rule by the given class name and arguments. |
||
27 | * |
||
28 | * @param string $class |
||
29 | * @param array $arguments |
||
30 | * |
||
31 | * @return object|RuleInterface |
||
32 | * @throws UnexpectedValueException |
||
33 | * @throws ReflectionException |
||
34 | */ |
||
35 | public function makeWithArgs($class, array $arguments = []) |
||
36 | { |
||
37 | return $this->reflect($class)->newInstanceArgs($arguments); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Creates reflection object for the given class name. |
||
42 | * |
||
43 | * @param string $class |
||
44 | * |
||
45 | * @return ReflectionClass |
||
46 | * @throws ReflectionException |
||
47 | */ |
||
48 | private function reflect($class) |
||
61 | } |
||
62 | } |
||
63 |