| Total Complexity | 6 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | class FormatterService implements FormatterServiceInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Ensures all the formatters will implement the same interface. |
||
| 14 | * |
||
| 15 | * @param object $formatter |
||
| 16 | */ |
||
| 17 | 73 | public static function ensureFormatterImplementsInterface(object $formatter): void |
|
| 18 | { |
||
| 19 | 73 | if (! $formatter instanceof Formatter) { |
|
| 20 | 2 | if (config('formatters.bindings_case') === 'camel') { |
|
| 21 | 1 | throw new ShouldNotUseCamelCaseException(); |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | throw new ShouldImplementInterfaceException(); |
|
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Unwrap the array if it is only one passed parameter. |
||
| 30 | * |
||
| 31 | * @param mixed $items |
||
| 32 | * |
||
| 33 | * @return mixed |
||
| 34 | */ |
||
| 35 | 75 | public static function unwrapIfArray(mixed $items): mixed |
|
| 44 | } |
||
| 45 | } |
||
| 46 |