AbstractModel::setCreationDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine\Blog\Model;
6
7
use DateTimeImmutable;
8
use Doctrine\ORM\Mapping as ORM;
9
use GraphQL\Doctrine\Attribute as API;
10
use GraphQLTests\Doctrine\Blog\Filtering\ModuloOperatorType;
11
use GraphQLTests\Doctrine\Blog\Sorting\PseudoRandom;
12
use GraphQLTests\Doctrine\Blog\Types\DateTimeType;
13
14
/**
15
 * Base class for all objects stored in database.
16
 */
17
#[ORM\MappedSuperclass]
18
#[API\Sorting(PseudoRandom::class)]
19
#[API\Filter(field: 'id', operator: ModuloOperatorType::class, type: 'int')]
20
abstract class AbstractModel
21
{
22
    #[ORM\Column(type: 'integer', options: ['unsigned' => true])]
23
    #[ORM\Id]
24
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
25
    protected ?int $id = null;
26
27
    #[ORM\Column(type: 'datetime_immutable')]
28
    private $creationDate;
29
30
    public function getId(): int
31
    {
32
        return $this->id;
33
    }
34
35
    #[API\Field(type: DateTimeType::class)]
36
    public function getCreationDate(): DateTimeImmutable
37
    {
38
        return $this->creationDate;
39
    }
40
41
    #[API\Input(type: DateTimeType::class)]
42
    public function setCreationDate(DateTimeImmutable $creationDate): void
43
    {
44
        $this->creationDate = $creationDate;
45
    }
46
}
47