RequestLog::isSuccessful()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Entity\System;
12
13
use App\Entity\EntityInterface;
14
use App\Entity\Parking\Member;
15
use App\Entity\Traits;
16
use App\Enum\Entity\RequestLogTypeEnum;
17
use Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\ORM\Mapping as ORM;
19
use PascalDeVink\ShortUuid\ShortUuid;
20
use Symfony\Component\Validator\Constraints as Assert;
21
22
/**
23
 * @ORM\Entity()
24
 * @ORM\Table(name="system_request_logs")
25
 */
26
class RequestLog implements EntityInterface
27
{
28
    use Traits\PropertyIdGeneratedTrait;
29
30
    /**
31
     * @var \DateTimeImmutable
32
     * @ORM\Column(name="started_at", type="datetime_immutable", nullable=false)
33
     * @Assert\NotBlank()
34
     */
35
    private $startedAt;
36
37
    /**
38
     * @var \DateTimeImmutable|null
39
     * @ORM\Column(name="finished_at", type="datetime_immutable", nullable=true)
40
     * @Assert\NotBlank()
41
     */
42
    private $finishedAt;
43
44
    /**
45
     * @var string
46
     * @ORM\Column(name="type", type="string", length=50, nullable=false)
47
     */
48
    private $type;
49
50
    /**
51
     * @var string
52
     * @ORM\Column(name="base_path", type="string", length=255, nullable=false)
53
     */
54
    private $basePath;
55
56
    /**
57
     * @var int
58
     * @ORM\Column(name="mili_seconds", type="integer", nullable=false)
59
     */
60
    private $miliSeconds;
61
62
    /**
63
     * @var bool
64
     * @ORM\Column(name="successfull", type="boolean", nullable=false)
65
     */
66
    private $successful;
67
68
    //-------------------------------------------------------------------------------------------
69
    /**
70
     * @var ArrayCollection|RequestLogDetail[]
71
     * @ORM\OneToMany(targetEntity="App\Entity\System\RequestLogDetail", mappedBy="requestLog")
72
     */
73
    private $requestLogDetails;
74
75
    /**
76
     * @var Member|null
77
     * @ORM\ManyToOne(targetEntity="App\Entity\Parking\Member")
78
     * @ORM\JoinColumn(name="member_id", referencedColumnName="id", nullable=true)
79
     */
80
    private $member;
81
82
    //-------------------------------------------------------------------------------------------
83
84 16
    public function __construct(
85
        RequestLogTypeEnum $type,
86
        string $basePath,
87
        \DateTimeImmutable $startedAt,
88
        Member $member = null
89
    ) {
90 16
        $this->id = ShortUuid::uuid4();
91 16
        $this->member = $member;
92 16
        $this->startedAt = $startedAt;
93 16
        $this->type = $type->getValue();
94 16
        $this->basePath = $basePath;
95 16
        $this->miliSeconds = 0;
96 16
        $this->successful = false;
97 16
        $this->requestLogDetails = new ArrayCollection();
98 16
    }
99
100
    //-------------------------------------------------------------------------------------------
101
102
    public function getStartedAt(): \DateTimeImmutable
103
    {
104
        return $this->startedAt;
105
    }
106
107
    /**
108
     * @return \DateTimeImmutable|null
109
     */
110
    public function getFinishedAt(): ?\DateTimeImmutable
111
    {
112
        return $this->finishedAt;
113
    }
114
115 16
    public function setFinishedAt(\DateTimeImmutable $finishedAt): self
116
    {
117 16
        $this->finishedAt = $finishedAt;
118
119 16
        return $this;
120
    }
121
122
    public function getType(): string
123
    {
124
        return $this->type;
125
    }
126
127
    public function getBasePath(): string
128
    {
129
        return $this->basePath;
130
    }
131
132
    public function getMiliSeconds(): int
133
    {
134
        return $this->miliSeconds;
135
    }
136
137
    public function setMiliSeconds(int $miliSeconds): self
138
    {
139
        $this->miliSeconds = $miliSeconds;
140
141
        return $this;
142
    }
143
144
    public function isSuccessful(): bool
145
    {
146
        return $this->successful;
147
    }
148
149 16
    public function setSuccessful(bool $successful): self
150
    {
151 16
        $this->successful = $successful;
152
153 16
        return $this;
154
    }
155
156
    /**
157
     * @return RequestLogDetail[]|ArrayCollection
158
     */
159
    public function getRequestLogDetails(): ArrayCollection
160
    {
161
        return $this->requestLogDetails;
162
    }
163
164
    /**
165
     * @param RequestLogDetail[]|ArrayCollection $requestLogDetails
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $requestLogDetails a bit more specific; maybe use ArrayCollection.
Loading history...
166
     */
167
    public function setRequestLogDetails(ArrayCollection $requestLogDetails): self
168
    {
169
        $this->requestLogDetails = $requestLogDetails;
170
171
        return $this;
172
    }
173
174
    public function getMember(): ?Member
175
    {
176
        return $this->member;
177
    }
178
179
    public function setMember(?Member $member): self
180
    {
181
        $this->member = $member;
182
183
        return $this;
184
    }
185
}
186