Completed
Push — master ( c3ce72...f2565d )
by Paweł
20s
created

ArticleStatistics::addEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Analytics Bundle.
5
 *
6
 * Copyright 2017 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2017 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\AnalyticsBundle\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
use Doctrine\Common\Collections\Collection;
19
use SWP\Bundle\ContentBundle\Model\ArticleInterface;
20
use SWP\Component\Common\Model\TimestampableInterface;
21
use SWP\Component\Common\Model\TimestampableTrait;
22
23
/**
24
 * Class ArticleStatistics.
25
 */
26
class ArticleStatistics implements ArticleStatisticsInterface, TimestampableInterface
27
{
28
    use TimestampableTrait;
29
30
    /**
31
     * @var int
32
     */
33
    protected $id;
34
35
    /**
36
     * @var ArticleInterface
37
     */
38
    protected $article;
39
40
    /**
41
     * @var int
42
     */
43
    protected $impressionsNumber = 0;
44
45
    /**
46
     * @var int
47
     */
48
    protected $pageViewsNumber = 0;
49
50
    /**
51
     * @var Collection
52
     */
53
    protected $events;
54
55
    /**
56
     * ArticleStatistics constructor.
57
     */
58
    public function __construct()
59
    {
60
        $this->events = new ArrayCollection();
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function getArticle(): ArticleInterface
75
    {
76
        return $this->article;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function setArticle(ArticleInterface $article): void
83
    {
84
        $this->article = $article;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function getImpressionsNumber(): int
91
    {
92
        return $this->impressionsNumber;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function setImpressionsNumber(int $impressionsNumber): void
99
    {
100
        $this->impressionsNumber = $impressionsNumber;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function getPageViewsNumber(): int
107
    {
108
        return $this->pageViewsNumber;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function setPageViewsNumber(int $pageViewsNumber): void
115
    {
116
        $this->pageViewsNumber = $pageViewsNumber;
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122
    public function increasePageViewsNumber(): void
123
    {
124
        $this->pageViewsNumber = $this->pageViewsNumber + 1;
125
    }
126
127
    /**
128
     * {@inheritdoc}
129
     */
130
    public function getEvents(): Collection
131
    {
132
        return $this->events;
133
    }
134
135
    /**
136
     * {@inheritdoc}
137
     */
138
    public function setEvents(Collection $events): void
139
    {
140
        $this->events = $events;
141
    }
142
143
    /**
144
     * {@inheritdoc}
145
     */
146
    public function addEvent(ArticleEventInterface $articleEvent): void
147
    {
148
        $this->events->add($articleEvent);
149
    }
150
}
151