| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function transform($entity) |
||
| 23 | { |
||
| 24 | if (null === $entity) { |
||
| 25 | return ''; |
||
| 26 | } |
||
| 27 | if (!is_subclass_of($entity, $this->entityClass)) { |
||
| 28 | throw new \InvalidArgumentException(sprintf( |
||
| 29 | 'Unsupported entity "%s" into "%s" loader.', |
||
| 30 | get_class($entity), |
||
| 31 | __CLASS__ |
||
| 32 | )); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $entity->getId(); |
||
| 36 | } |
||
| 37 | |||
| 59 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: