| Conditions | 1 |
| Paths | 1 |
| Total Lines | 16 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 1 | public function serialise(EntityInterface $entity) |
|
| 26 | { |
||
| 27 | 1 | $properties = []; |
|
| 28 | 1 | $properties[] = $entity->getAnchorPoint(); |
|
|
|
|||
| 29 | 1 | $properties[] = $entity->getXPos(); |
|
| 30 | 1 | $properties[] = $entity->getYPos(); |
|
| 31 | 1 | $properties[] = $entity->getWidth(); |
|
| 32 | 1 | $properties[] = $entity->getHeight(); |
|
| 33 | 1 | $properties[] = $entity->getOrion(); |
|
| 34 | 1 | $properties[] = $this->stringEscaper->escape($entity->getDescription()); |
|
| 35 | 1 | $properties[] = $entity->getThickness(); |
|
| 36 | 1 | $properties[] = $entity->getArc(); |
|
| 37 | 1 | $properties[] = $entity->getPhantomField(); |
|
| 38 | |||
| 39 | 1 | return implode(',', $properties); |
|
| 40 | } |
||
| 41 | } |
||
| 42 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: