Passed
Push — master ( 396bec...2c40af )
by Luiz Kim
08:29
created

Contract::setCreationDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use ApiPlatform\Metadata\GetCollection;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ApiPlatform\Metadata\Post;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Post was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ApiPlatform\Metadata\Put;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Put was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use ApiPlatform\Metadata\Get;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use ApiPlatform\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use ApiPlatform\Metadata\ApiProperty;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiProperty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use ApiPlatform\Metadata\ApiFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use DateTime;
13
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Serializer\Annotation\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Annotation\Groups was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
/**
18
 * @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class})
19
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\ContractRepository")
20
 */
21
#[ApiResource(
22
    operations: [
23
        new Get(security: 'is_granted(\'ROLE_CLIENT\')'),
24
        new Put(
25
            security: 'is_granted(\'ROLE_CLIENT\')',
26
            uriTemplate: '/contracts/{id}/change/payment',
27
            controller: \App\Controller\ChangeContractPaymentAction::class
28
        ),
29
        new Put(
30
            security: 'is_granted(\'ROLE_CLIENT\')',
31
            uriTemplate: '/contracts/{id}/change',
32
            controller: \App\Controller\ChangeContractAction::class
33
        ),
34
        new Put(
35
            uriTemplate: 'contracts/{id}/status/{status}',
36
            controller: \App\Controller\ChangeContractStatusAction::class,
37
            openapiContext: []
38
        ),
39
        new Post(),
40
        new GetCollection()
41
    ],
42
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']]
43
)]
44
class Contract
45
{
46
    /**
47
     * @ORM\Column(type="integer", nullable=false)
48
     * @ORM\Id
49
     * @ORM\GeneratedValue(strategy="IDENTITY")
50
     * @Groups({"contract_people:read","logistic_read"})
51
     */
52
    private $id;
53
    /**
54
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
55
     * @ORM\JoinColumns({
56
     *   @ORM\JoinColumn(referencedColumnName="id", nullable=false)
57
     * })
58
     */
59
    private $contractModel;
60
    /**
61
     * @ORM\Column(name="contract_status", type="string")
62
     * @Groups("contract_people:read")
63
     */
64
    private $contractStatus;
65
    //, columnDefinition="enum('Active', 'Canceled', 'Amended')"
66
    /**
67
     * @ORM\Column(name="doc_key", type="string")
68
     * @Groups("contract_people:read")
69
     */
70
    private $doc_key;
71
    /**
72
     * @ORM\Column(name="start_date", type="datetime",  nullable=false)
73
     * @Groups("contract_people:read")
74
     */
75
    private $startDate;
76
    /**
77
     * @ORM\Column(name="end_date", type="datetime",  nullable=false)
78
     * @Groups("contract_people:read")
79
     */
80
    private $endDate;
81
    /**
82
     * @ORM\Column(name="creation_date", type="datetime",  nullable=false)
83
     */
84
    private $creationDate;
85
    /**
86
     * @ORM\Column(name="alter_date", type="datetime",  nullable=false)
87
     */
88
    private $alterDate;
89
    /**
90
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
91
     * @ORM\JoinColumns({
92
     *   @ORM\JoinColumn(name="contract_parent_id", referencedColumnName="id", nullable=true)
93
     * })
94
     */
95
    private $contractParent;
96
    /**
97
     * Many Contracts have Many Peoples.
98
     *
99
     * @ORM\ManyToMany(targetEntity="ControleOnline\Entity\People")
100
     * @ORM\JoinTable(name="contract_people",
101
     *      joinColumns={@ORM\JoinColumn(name="contract_id", referencedColumnName="id")},
102
     *      inverseJoinColumns={@ORM\JoinColumn(name="people_id", referencedColumnName="id")}
103
     *      )
104
     */
105
    private $peoples;
106
107
108
    public function __construct()
109
    {
110
        $this->startDate = new DateTime('now');
111
        $this->endDate = new DateTime('now');
112
        $this->creationDate = new DateTime('now');
113
        $this->alterDate = new DateTime('now');
114
    }
115
    public function getId(): int
116
    {
117
        return $this->id;
118
    }
119
    public function getFile(): File
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\File was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
120
    {
121
        return $this->contractModel;
122
    }
123
    public function setFile(File $document_model): Contract
124
    {
125
        $this->contractModel = $document_model;
126
        return $this;
127
    }
128
    public function getKey(): ?string
129
    {
130
        return $this->doc_key;
131
    }
132
    public function setKey(string $doc_key): Contract
133
    {
134
        $this->doc_key = $doc_key;
135
        return $this;
136
    }
137
    public function getContractStatus(): string
138
    {
139
        return $this->contractStatus;
140
    }
141
    public function setContractStatus(string $contract_status): Contract
142
    {
143
        $this->contractStatus = $contract_status;
144
        return $this;
145
    }
146
    public function getStartDate(): DateTime
147
    {
148
        return $this->startDate;
149
    }
150
    public function setStartDate(DateTime $start_date): Contract
151
    {
152
        $this->startDate = $start_date;
153
        return $this;
154
    }
155
    public function getEndDate(): ?DateTime
156
    {
157
        return $this->endDate;
158
    }
159
    public function setEndDate(DateTime $end_date): Contract
160
    {
161
        $this->endDate = $end_date;
162
        return $this;
163
    }
164
    public function getCreationDate(): DateTime
165
    {
166
        return $this->creationDate;
167
    }
168
    public function setCreationDate(DateTime $creation_date): Contract
169
    {
170
        $this->creationDate = $creation_date;
171
        return $this;
172
    }
173
    public function getAlterDate(): DateTime
174
    {
175
        return $this->alterDate;
176
    }
177
    public function setAlterDate(DateTime $alter_date): Contract
178
    {
179
        $this->alterDate = $alter_date;
180
        return $this;
181
    }
182
    /**
183
     * @return mixed
184
     */
185
    public function getContractParent()
186
    {
187
        return $this->contractParent;
188
    }
189
    public function setContractParentId(Contract $contractParent): Contract
190
    {
191
        $this->contractParent = $contractParent;
192
        return $this;
193
    }
194
    public function getPeoples(): Collection
195
    {
196
        return $this->peoples;
197
    }
198
}
199