RelatedSite   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 0
dl 0
loc 87
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A fromProperties() 0 15 1
B fromJson() 0 11 5
A setApiSiteParameter() 0 6 1
A getApiSiteParameter() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setRelation() 0 8 2
A getRelation() 0 4 1
A setSiteUrl() 0 6 1
A getSiteUrl() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
/*
14
 * This file is part of the Stack Exchange Api Client library.
15
 *
16
 * (c) Beñat Espiña <[email protected]>
17
 *
18
 * For the full copyright and license information, please view the LICENSE
19
 * file that was distributed with this source code.
20
 */
21
22
namespace BenatEspina\StackExchangeApiClient\Model;
23
24
/**
25
 * The access token model class.
26
 *
27
 * @author Beñat Espiña <[email protected]>
28
 */
29
class RelatedSite implements Model
30
{
31
    const RELATIONS = ['chat', 'meta', 'parent'];
32
33
    protected $apiSiteParameter;
34
    protected $name;
35
    protected $relation;
36
    protected $siteUrl;
37
38
    public static function fromProperties(
39
        $apiSiteParameter,
40
        $name,
41
        $relation,
42
        $siteUrl
43
    ) {
44
        $instance = new self();
45
        $instance
46
            ->setApiSiteParameter($apiSiteParameter)
47
            ->setName($name)
48
            ->setRelation($relation)
49
            ->setSiteUrl($siteUrl);
50
51
        return $instance;
52
    }
53
54
    public static function fromJson(array $data)
55
    {
56
        $instance = new self();
57
        $instance
58
            ->setApiSiteParameter(array_key_exists('api_site_parameter', $data) ? $data['api_site_parameter'] : null)
59
            ->setName(array_key_exists('name', $data) ? $data['name'] : null)
60
            ->setName(array_key_exists('relation', $data) ? $data['relation'] : null)
61
            ->setName(array_key_exists('site_url', $data) ? $data['site_url'] : null);
62
63
        return $instance;
64
    }
65
66
    public function setApiSiteParameter($apiSiteParameter)
67
    {
68
        $this->apiSiteParameter = $apiSiteParameter;
69
70
        return $this;
71
    }
72
73
    public function getApiSiteParameter()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
74
    {
75
        return $this->apiSiteParameter;
76
    }
77
78
    public function setName($name)
79
    {
80
        $this->name = $name;
81
82
        return $this;
83
    }
84
85
    public function getName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
86
    {
87
        return $this->name;
88
    }
89
90
    public function setRelation($relation)
91
    {
92
        if (in_array($relation, self::RELATIONS, true)) {
93
            $this->relation = $relation;
94
        }
95
96
        return $this;
97
    }
98
99
    public function getRelation()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
100
    {
101
        return $this->relation;
102
    }
103
104
    public function setSiteUrl($siteUrl)
105
    {
106
        $this->siteUrl = $siteUrl;
107
108
        return $this;
109
    }
110
111
    public function getSiteUrl()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
112
    {
113
        return $this->siteUrl;
114
    }
115
}
116