Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
48 | protected function getFromContainer($type = null, $required = true) |
||
49 | { |
||
50 | if (isset($this->container)) { |
||
51 | $item = $this->container->get($this->containerId); |
||
52 | |||
53 | if ($type !== null && !is_a($item, $type)) { |
||
54 | throw new InvalidArgumentException("Invalid argument, it's not of type '{$type}'"); |
||
55 | } |
||
56 | |||
57 | return $item; |
||
58 | } |
||
59 | |||
60 | if ($required) { |
||
61 | $class = get_class($this); |
||
62 | |||
63 | throw new RuntimeException("Missing required '{$type}' in the middleware '{$class}'"); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 |