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