Passed
Pull Request — master (#13)
by Tom
02:31
created

UserPost::getCreatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine\Blog\Model;
6
7
use DateTime;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\Common\Collections\Collection;
10
use Doctrine\ORM\Mapping as ORM;
11
use GraphQL\Doctrine\Annotation as API;
12
13
/**
14
 * A many to many from author to post
15
 * This is intended to be invalid for GraphQL because it has a compound
16
 * primary key and is not a Many to Many join table in native Doctrine.
17
 *
18
 * @ORM\Entity
19
 */
20
final class UserPost
21
{
22
    /**
23
     * @var int
24
     *
25
     * @ORM\Column(type="integer", options={"unsigned" = true})
26
     * @ORM\Id
27
     */
28
    protected $user_id;
29
30
    /**
31
     * @var int
32
     *
33
     * @ORM\Column(type="integer", options={"unsigned" = true})
34
     * @ORM\Id
35
     */
36
    protected $post_id;
37
38
    /**
39
     * @var datetime
40
     *
41
     * @ORM\Column(name="created_at", type="datetime")
42
     */
43
    private $createdAt;
44
45
    /**
46
     * Constructor
47
     *
48
     * @param null|int $id
49
     */
50
    public function __construct(?array $id = [])
51
    {
52
        // This is a bad idea in real world, but we are just testing stuff here
53
        $this->user_id = $id['user_id'];
54
        $this->post_id = $id['post_id'];
55
        $this->createdAt = new DateTime();
56
    }
57
    /**
58
     * Get the date the record was created
59
     *
60
     * @return datetime
61
     */
62
    public function getCreatedAt(): datetime
63
    {
64
        return $this->createdAt;
65
    }
66
}
67