Conditions | 4 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4.3731 |
Changes | 0 |
1 | <?php |
||
46 | 152 | public function get($id) |
|
47 | { |
||
48 | 152 | if (!$this->has($id)) { |
|
49 | 2 | throw ConstraintNotFoundException::forRule($id); |
|
50 | } |
||
51 | |||
52 | 150 | $concrete = $this->rules()[$id]; |
|
53 | |||
54 | try { |
||
55 | 150 | return is_string($concrete) ? new $concrete() : $concrete(); |
|
56 | } catch (\Exception $e) { |
||
57 | throw ConstraintException::forRule($id, $e); |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 |