Passed
Push — master ( fd3cd2...25f15e )
by Alexey
03:28
created

SubscriptionEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 83
ccs 8
cts 16
cp 0.5
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getId() 0 4 1
A getDate() 0 4 1
A getSubscriber() 0 4 1
A getAuthor() 0 4 1
A getAction() 0 4 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Table(name="log", schema="subscriptions", indexes={
9
 *      @ORM\Index(name="author_idx", columns={"author_id"}),
10
 *      @ORM\Index(name="subscriber_idx", columns={"subscriber_id"}),
11
 *      @ORM\Index(name="date_idx", columns={"date"})
12
 * })
13
 * @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository", readOnly=true)
14
 */
15
class SubscriptionEvent
16
{
17
    const ACTION_SUBSCRIBE = 'subscribe';
18
    const ACTION_UNSUBSCRIBE = 'unsubscribe';
19
20
    /**
21
     * @var int
22
     *
23
     * @ORM\Column(name="id", type="integer")
24
     * @ORM\Id
25
     * @ORM\GeneratedValue(strategy="AUTO")
26
     */
27
    private $id;
28
29
    /**
30
     * @var User Blog author
31
     *
32
     * @ORM\ManyToOne(targetEntity="User", inversedBy="newSubscriberEvents")
33
     * @ORM\JoinColumn(name="author_id", nullable=false)
34
     */
35
    private $author;
36
37
    /**
38
     * @var User Blog subscriber
39
     *
40
     * @ORM\ManyToOne(targetEntity="User")
41
     * @ORM\JoinColumn(name="subscriber_id", nullable=false)
42
     */
43
    private $subscriber;
44
    
45
    /**
46
     * @var \DateTime
47
     *
48
     * @ORM\Column(name="date", type="datetime", nullable=false)
49
     */
50
    private $date;
51
52
    /**
53
     * @var string
54
     *
55
     * @ORM\Column(name="action", type="string", length=12, nullable=false)
56
     */
57
    private $action;
58
59
60
    /**
61
     * @param User $author
62
     * @param User $subscriber
63
     * @param string $action
64
     */
65
    public function __construct(User $author, User $subscriber, string $action = self::ACTION_SUBSCRIBE)
66
    {
67
        $this->author = $author;
68
        $this->subscriber = $subscriber;
69
        $this->action = $action;
70
        $this->date = new \DateTime();
71
    }
72
73
    public function getId(): int
74
    {
75
        return $this->id;
76
    }
77
78 5
    public function getDate(): \DateTime
79
    {
80 5
        return $this->date;
81
    }
82
83 5
    public function getSubscriber(): User
84
    {
85 5
        return $this->subscriber;
86
    }
87
88 2
    public function getAuthor(): User
89
    {
90 2
        return $this->author;
91
    }
92
93 5
    public function getAction(): string
94
    {
95 5
        return $this->action;
96
    }
97
}
98