Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
20.00% covered (danger)
20.00%
2 / 10
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
AuditModified
20.00% covered (danger)
20.00%
2 / 10
50.00% covered (danger)
50.00%
2 / 4
12.19
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 / 7
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\AuditLogEventMessage;
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        return NonEmptyString::fromNative(
34            $translator->getGeneralTranslation(
35                $context,
36                AuditLogEventMessage::createResourceModifiedEvent($context)
37            )
38        );
39    }
40}