Completed
Pull Request — master (#13)
by Tom
03:57 queued 01:44
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\ORM\Mapping as ORM;
9
10
/**
11
 * A many to many from author to post
12
 * This is intended to be invalid for GraphQL because it has a compound
13
 * primary key and is not a Many to Many join table in native Doctrine.
14
 *
15
 * @ORM\Entity
16
 */
17
final class UserPost
18
{
19
    /**
20
     * @var int
21
     *
22
     * @ORM\Column(type="integer", options={"unsigned" = true})
23
     * @ORM\Id
24
     */
25
    private $user_id;
26
27
    /**
28
     * @var int
29
     *
30
     * @ORM\Column(type="integer", options={"unsigned" = true})
31
     * @ORM\Id
32
     */
33
    private $post_id;
34
35
    /**
36
     * @var datetime
37
     *
38
     * @ORM\Column(name="created_at", type="datetime")
39
     */
40
    private $createdAt;
41
42
    /**
43
     * Constructor
44
     *
45
     * @param null|int $id
46
     */
47
    public function __construct(?array $id = [])
48
    {
49
        // This is a bad idea in real world, but we are just testing stuff here
50
        $this->user_id = $id['user_id'];
51
        $this->post_id = $id['post_id'];
52
        $this->createdAt = new DateTime();
53
    }
54
55
    /**
56
     * Get the date the record was created
57
     *
58
     * @return datetime
59
     */
60
    public function getCreatedAt(): datetime
61
    {
62
        return $this->createdAt;
63
    }
64
}
65