| Conditions | 7 |
| Paths | 7 |
| Total Lines | 20 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | public function getEntityLabel($entity) |
||
| 11 | { |
||
| 12 | $label = ''; |
||
| 13 | $accessor = PropertyAccess::createPropertyAccessor(); |
||
| 14 | |||
| 15 | if ($accessor->isReadable($entity, 'label')) { |
||
| 16 | $label = $entity->getLabel(); |
||
| 17 | } else if ($accessor->isReadable($entity, 'title')) { |
||
| 18 | $label = $entity->getTitle(); |
||
| 19 | } else if ($accessor->isReadable($entity, 'name')) { |
||
| 20 | $label = $entity->getName(); |
||
| 21 | } else if ($accessor->isReadable($entity, '__toString')) { |
||
| 22 | $label = $entity->__toString(); |
||
| 23 | } else if ($accessor->isReadable($entity, 'content')) { |
||
| 24 | $label = strip_tags(substr($entity->getContent(), 0, 100)); |
||
| 25 | } else if ($accessor->isReadable($entity, 'id')) { |
||
| 26 | $label = $entity->getId(); |
||
| 27 | } |
||
| 28 | return $label; |
||
| 29 | } |
||
| 30 | } |
||
| 31 |