Completed
Push — master ( 5ec4be...3f1e8c )
by Paweł
08:46
created

ArticleStatistics   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 12
lcom 2
cbo 2
dl 0
loc 72
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getArticle() 0 4 1
A setArticle() 0 4 1
A getImpressionsNumber() 0 8 2
A setImpressionsNumber() 0 4 1
A getPageViewsNumber() 0 8 2
A setPageViewsNumber() 0 4 1
A getInternalClickRate() 0 4 1
A setInternalClickRate() 0 4 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\DateTime;
19
use SWP\Component\Common\Model\TimestampableInterface;
20
use SWP\Component\Common\Model\TimestampableTrait;
21
22
class ArticleStatistics implements ArticleStatisticsInterface, TimestampableInterface
23
{
24
    use TimestampableTrait;
25
26
    protected $id;
27
28
    protected $article;
29
30
    protected $impressionsNumber = 0;
31
32
    protected $pageViewsNumber = 0;
33
34
    protected $internalClickRate = 0;
35
36
    public function __construct()
37
    {
38
        $this->createdAt = DateTime::getCurrentDateTime();
39
    }
40
41
    public function getId()
42
    {
43
        return $this->id;
44
    }
45
46
    public function getArticle(): ArticleInterface
47
    {
48
        return $this->article;
49
    }
50
51
    public function setArticle(ArticleInterface $article): void
52
    {
53
        $this->article = $article;
54
    }
55
56
    public function getImpressionsNumber(): int
57
    {
58
        if (null === $this->impressionsNumber) {
59
            return 0;
60
        }
61
62
        return $this->impressionsNumber;
63
    }
64
65
    public function setImpressionsNumber(int $impressionsNumber): void
66
    {
67
        $this->impressionsNumber = $impressionsNumber;
68
    }
69
70
    public function getPageViewsNumber(): int
71
    {
72
        if (null === $this->pageViewsNumber) {
73
            return 0;
74
        }
75
76
        return $this->pageViewsNumber;
77
    }
78
79
    public function setPageViewsNumber(int $pageViewsNumber): void
80
    {
81
        $this->pageViewsNumber = $pageViewsNumber;
82
    }
83
84
    public function getInternalClickRate(): float
85
    {
86
        return $this->internalClickRate;
87
    }
88
89
    public function setInternalClickRate(float $internalClickRate): void
90
    {
91
        $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...
92
    }
93
}
94