| Conditions | 5 |
| Paths | 9 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5.5069 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 32 | public function prePersist(LifecycleEventArgs $args): void |
|
| 16 | { |
||
| 17 | 32 | $entity = $args->getEntity(); |
|
| 18 | |||
| 19 | 32 | if (is_a($entity, CreatedEntityInterface::class)) { |
|
| 20 | /** @var CreatedEntityInterface $createdEntity */ |
||
| 21 | 32 | $createdEntity = $entity; |
|
| 22 | 32 | if (null === $createdEntity->getCreated()) { |
|
| 23 | 32 | $createdEntity->setCreated(new DateTime()); |
|
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | 32 | if (is_a($entity, CreatedTimestampEntityInterface::class)) { |
|
| 28 | /** @var CreatedTimestampEntityInterface $createdTimestampEntity */ |
||
| 29 | $createdTimestampEntity = $entity; |
||
| 30 | if (null === $createdTimestampEntity->getCreatedTimestamp()) { |
||
| 31 | $createdTimestampEntity->setCreatedTimestamp((int)(microtime(true) * 1000)); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | 32 | } |
|
| 35 | } |
||
| 36 |