Passed
Pull Request — master (#63)
by Mark
23:06
created

AbstractModel::getCreationDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine\AttributeBlog\Model;
6
7
use DateTimeImmutable;
8
use Doctrine\ORM\Mapping as ORM;
9
use GraphQL\Doctrine\Annotation 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\Filters(new API\Filter(field: 'id', operator: ModuloOperatorType::class, type: 'int'))]
20
abstract class AbstractModel
21
{
22
    /** @var int */
23
    #[ORM\Column(type: 'integer', options: ['unsigned' => true])]
24
    #[ORM\Id]
25
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
26
    protected $id;
27
28
    #[ORM\Column(type: 'datetime_immutable')]
29
    private $creationDate;
30
31
    public function getId(): int
32
    {
33
        return $this->id;
34
    }
35
36
    #[API\Field(type: DateTimeType::class)]
37
    public function getCreationDate(): DateTimeImmutable
38
    {
39
        return $this->creationDate;
40
    }
41
42
    #[API\Input(type: DateTimeType::class)]
43
    public function setCreationDate(DateTimeImmutable $creationDate): void
44
    {
45
        $this->creationDate = $creationDate;
46
    }
47
}
48