Period::setReferrers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of the badams\GoogleUrl library
4
 *
5
 * @license http://opensource.org/licenses/MIT
6
 * @link https://github.com/badams/google-url
7
 * @package badams/google-url
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace badams\GoogleUrl\Resources;
14
15
use \badams\GoogleUrl\Resource;
16
17
/**
18
 * Class Analytics
19
 * @package badams\GoogleUrl\Resources
20
 */
21
class Period extends Resource
22
{
23
    /**
24
     * Number of clicks on this short URL.
25
     *
26
     * @var integer
27
     */
28
    public $shortUrlClicks;
29
30
    /**
31
     * Number of clicks on all goo.gl short URLs pointing to this long URL.
32
     *
33
     * @var integer
34
     */
35
    public $longUrlClicks;
36
37
    /**
38
     * Top referring hosts, e.g. "www.google.com"; sorted by (descending) click counts. Only present if this data is available.
39
     *
40
     * @var Category[]
41
     */
42
    public $referrers = [];
43
44
    /**
45
     * Top countries (expressed as country codes), e.g. "US" or "DE"; sorted by (descending) click counts. Only present if this data is available.
46
     *
47
     * @var Category[]
48
     */
49
    public $countries = [];
50
51
    /**
52
     * Top browsers, e.g. "Chrome"; sorted by (descending) click counts. Only present if this data is available.
53
     *
54
     * @var Category[]
55
     */
56
    public $browsers = [];
57
58
    /**
59
     * Top platforms or OSes, e.g. "Windows"; sorted by (descending) click counts. Only present if this data is available.
60
     *
61
     * @var Category[]
62
     */
63
    public $platforms = [];
64
65
    /**
66
     * Populates the referrers list
67
     *
68
     * @param $list
69
     */
70 3
    public function setReferrers($list)
71
    {
72 3
        foreach ($list as $category) {
73 3
            $this->referrers[] = Category::createFromJson($category);
74 2
        }
75 3
    }
76
77
    /**
78
     * Populates the countries list
79
     *
80
     * @param $list
81
     */
82 3
    public function setCountries($list)
83
    {
84 3
        foreach ($list as $category) {
85 3
            $this->countries[] = Category::createFromJson($category);
86 2
        }
87 3
    }
88
89
    /**
90
     * Populates the browsers list
91
     *
92
     * @param $list
93
     */
94 3
    public function setBrowsers($list)
95
    {
96 3
        foreach ($list as $category) {
97 3
            $this->browsers[] = Category::createFromJson($category);
98 2
        }
99 3
    }
100
101
    /**
102
     * Populates the platforms list
103
     *
104
     * @param $list
105
     */
106 3
    public function setPlatforms($list)
107
    {
108 3
        foreach ($list as $category) {
109 3
            $this->platforms[] = Category::createFromJson($category);
110 2
        }
111 3
    }
112
}
113