| Conditions | 6 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 13.776 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | function validate_all_present() |
||
| 11 | { |
||
| 12 | $args = func_get_args(); |
||
| 13 | |||
| 14 | if (!Check::allPresent($args)) { |
||
| 15 | $errorMessage = 'At least one required variable is not present.'; |
||
| 16 | 15 | ||
| 17 | // show the variable location on the debug mode |
||
| 18 | 15 | if (getenv('APP_DEBUG') === 'true') { |
|
| 19 | 12 | // show the argument location for easier debugging |
|
| 20 | $backtrace = debug_backtrace(); |
||
| 21 | |||
| 22 | 12 | if (isset($backtrace[0])) { |
|
| 23 | $args = $backtrace[0]['args']; |
||
| 24 | |||
| 25 | foreach ($args as $i => $iValue) { |
||
| 26 | if ($iValue === null) { |
||
| 27 | $errorMessage .= ' Argument ' . ($i + 1) . ' is empty.'; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | throw new InvalidArgumentException($errorMessage); |
||
| 34 | } |
||
| 37 |