| Conditions | 6 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php namespace Arcanedev\LaravelHtml\Helpers; |
||
| 50 | 348 | private static function makeAttributeElement($key, $value) |
|
| 51 | { |
||
| 52 | 348 | if (is_null($value)) |
|
| 53 | 261 | return null; |
|
| 54 | |||
| 55 | // For numeric keys we will assume that the key and the value are the same |
||
| 56 | // as this will convert HTML attributes such as "required" to a correct |
||
| 57 | // form like required="required" instead of using incorrect numerics. |
||
| 58 | 342 | if (is_numeric($key)) |
|
| 59 | 9 | return $value; |
|
| 60 | |||
| 61 | 342 | if (is_bool($value) && $key !== 'value') |
|
| 62 | 3 | return $value ? $key : ''; |
|
| 63 | |||
| 64 | 342 | return $key.'="'.e($value).'"'; |
|
| 65 | } |
||
| 66 | } |
||
| 67 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClassto useselfinstead: