| Conditions | 8 |
| Paths | 11 |
| Total Lines | 33 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function notEmpty($property, array $args=[]) |
||
|
|
|||
| 26 | { |
||
| 27 | $method = "get$property"; |
||
| 28 | |||
| 29 | if (!method_exists($this, $method)) { |
||
| 30 | throw new OutOfBoundsException("'$property' is not a valid property of '" . get_class($this) . "'"); |
||
| 31 | } |
||
| 32 | |||
| 33 | $value = count($args) |
||
| 34 | ? call_user_func_array([ $this, $method ], $args) |
||
| 35 | : $this->$method(); |
||
| 36 | |||
| 37 | if (null === $value) { // is_scalar does not consider 'null' to be scalar value. |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | |||
| 41 | if (is_scalar($value) || is_array($value)) { |
||
| 42 | return !empty($value); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (is_resource($value)) { |
||
| 46 | return true; |
||
| 47 | } |
||
| 48 | |||
| 49 | /* |
||
| 50 | * $value must be an object. |
||
| 51 | */ |
||
| 52 | if ($value instanceOf \Countable) { |
||
| 53 | return !(bool) count($value); |
||
| 54 | } |
||
| 55 | |||
| 56 | return false; |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.