Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
18.18% covered (danger)
18.18%
2 / 11
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
AuditModified
18.18% covered (danger)
18.18%
2 / 11
50.00% covered (danger)
50.00%
2 / 4
12.76
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEvent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContents
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDescription
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2namespace Apie\Common\Other\Audit;
3
4use Apie\Common\Enums\AuditLogEvent;
5use Apie\Core\Context\ApieContext;
6use Apie\Core\Entities\EntityInterface;
7use Apie\Core\Translator\ApieTranslatorInterface;
8use Apie\Core\Translator\ValueObjects\TranslationString;
9use Apie\Core\ValueObjects\NonEmptyString;
10
11class AuditModified implements AuditEvent
12{
13    public function __construct(
14        private mixed $contents
15    ) {
16    }
17    public function getEvent(): AuditLogEvent
18    {
19        return AuditLogEvent::Modified;
20    }
21
22    public function getContents(): mixed
23    {
24        return $this->contents;
25    }
26
27    public function getDescription(
28        ApieTranslatorInterface $translator,
29        ApieContext $context,
30        string|EntityInterface|null $entity,
31    ): NonEmptyString {
32        assert($entity !== null);
33        $refl = new \ReflectionClass($entity);
34        return NonEmptyString::fromNative(
35            $translator->getGeneralTranslation(
36                $context,
37                new TranslationString('audit_log.modified.' . $refl->getShortName())
38            )
39        );
40    }
41}