| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function getPolicy($resource) |
||
| 32 | { |
||
| 33 | if (!is_string($resource)) { |
||
| 34 | $message = sprintf('Resource must be a string, `%s` given.', gettype($resource)); |
||
| 35 | throw new InvalidArgumentException($message); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (!class_exists($resource)) { |
||
| 39 | throw new MissingPolicyException(sprintf('Policy for `%s` has not been defined.', $resource)); |
||
| 40 | } |
||
| 41 | |||
| 42 | return new $resource(); |
||
| 43 | } |
||
| 45 |