UpdateActivityLogMessage   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 82
rs 10
wmc 15

15 Methods

Rating   Name   Duplication   Size   Complexity  
A isCreateLogWithoutChanges() 0 3 1
A getRequestUrl() 0 3 1
A getClassName() 0 3 1
A __construct() 0 4 1
A getActionName() 0 3 1
A setDateTime() 0 3 1
A getObjectId() 0 3 1
A getDateTime() 0 3 1
A setNormalizedItem() 0 3 1
A getNormalizedItem() 0 3 1
A setUser() 0 3 1
A getUser() 0 3 1
A setUpdatedItem() 0 3 1
A setRequestUrl() 0 3 1
A getUpdatedItem() 0 3 1
1
<?php
2
3
namespace Locastic\Loggastic\Message;
4
5
use Locastic\Loggastic\Enum\ActivityLogAction;
6
use Locastic\Loggastic\Util\ClassUtils;
7
8
final class UpdateActivityLogMessage implements UpdateActivityLogMessageInterface
9
{
10
    private \DateTime $dateTime;
11
    private string $actionName;
12
    private ?array $userInfo = null;
13
    private ?string $requestUrl = null;
14
    private array $normalizedItem = [];
15
16
    public function __construct(private object $updatedItem, ?string $actionName = null, private readonly bool $createLogWithoutChanges = false)
17
    {
18
        $this->dateTime = new \DateTime();
19
        $this->actionName = $actionName ?? ActivityLogAction::EDITED;
20
    }
21
22
    public function getDateTime(): \DateTime
23
    {
24
        return $this->dateTime;
25
    }
26
27
    public function setDateTime(\DateTime $dateTime): void
28
    {
29
        $this->dateTime = $dateTime;
30
    }
31
32
    public function getUpdatedItem(): object
33
    {
34
        return $this->updatedItem;
35
    }
36
37
    public function setUpdatedItem($updatedItem): void
38
    {
39
        $this->updatedItem = $updatedItem;
40
    }
41
42
    public function getActionName(): string
43
    {
44
        return $this->actionName;
45
    }
46
47
    public function isCreateLogWithoutChanges(): bool
48
    {
49
        return $this->createLogWithoutChanges;
50
    }
51
52
    public function getUser(): ?array
53
    {
54
        return $this->userInfo;
55
    }
56
57
    public function setUser(?array $userInfo): void
58
    {
59
        $this->userInfo = $userInfo;
60
    }
61
62
    public function getRequestUrl(): ?string
63
    {
64
        return $this->requestUrl;
65
    }
66
67
    public function setRequestUrl(?string $requestUrl): void
68
    {
69
        $this->requestUrl = $requestUrl;
70
    }
71
72
    public function getNormalizedItem(): array
73
    {
74
        return $this->normalizedItem;
75
    }
76
77
    public function setNormalizedItem(array $normalizedItem): void
78
    {
79
        $this->normalizedItem = $normalizedItem;
80
    }
81
82
    public function getObjectId()
83
    {
84
        return $this->getUpdatedItem()->getId();
85
    }
86
87
    public function getClassName(): string
88
    {
89
        return ClassUtils::getClass($this->getUpdatedItem());
90
    }
91
}
92