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