Completed
Pull Request — 2.0 (#954)
by Paweł
09:51
created

ArticleStatistics::setEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
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 SWP\Bundle\ContentBundle\Model\ArticleInterface;
18
use SWP\Component\Common\Model\TimestampableInterface;
19
use SWP\Component\Common\Model\TimestampableTrait;
20
21
class ArticleStatistics implements ArticleStatisticsInterface, TimestampableInterface
22
{
23
    use TimestampableTrait;
24
25
    protected $id;
26
27
    protected $article;
28
29
    protected $impressionsNumber = 0;
30
31
    protected $pageViewsNumber = 0;
32
33
    protected $internalClickRate = 0;
34
35
    public function getId()
36
    {
37
        return $this->id;
38
    }
39
40
    public function getArticle(): ArticleInterface
41
    {
42
        return $this->article;
43
    }
44
45
    public function setArticle(ArticleInterface $article): void
46
    {
47
        $this->article = $article;
48
    }
49
50
    public function getImpressionsNumber(): int
51
    {
52
        if (null === $this->impressionsNumber) {
53
            return 0;
54
        }
55
56
        return $this->impressionsNumber;
57
    }
58
59
    public function setImpressionsNumber(int $impressionsNumber): void
60
    {
61
        $this->impressionsNumber = $impressionsNumber;
62
    }
63
64
    public function getPageViewsNumber(): int
65
    {
66
        if (null === $this->pageViewsNumber) {
67
            return 0;
68
        }
69
70
        return $this->pageViewsNumber;
71
    }
72
73
    public function setPageViewsNumber(int $pageViewsNumber): void
74
    {
75
        $this->pageViewsNumber = $pageViewsNumber;
76
    }
77
78
    public function getInternalClickRate(): float
79
    {
80
        return $this->internalClickRate;
81
    }
82
83
    public function setInternalClickRate(float $internalClickRate): void
84
    {
85
        $this->internalClickRate = $internalClickRate;
0 ignored issues
show
Documentation Bug introduced by
The property $internalClickRate was declared of type integer, but $internalClickRate is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
86
    }
87
}
88