Completed
Push — v2 ( e6c7b3...40717e )
by Beñat
06:35
created

RelatedSite::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2014-2016 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
namespace BenatEspina\StackExchangeApiClient\Model;
13
14
/**
15
 * The access token model class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class RelatedSite implements Model
20
{
21
    const RELATIONS = ['chat', 'meta', 'parent'];
22
23
    protected $apiSiteParameter;
24
    protected $name;
25
    protected $relation;
26
    protected $siteUrl;
27
28
    public static function fromProperties(
29
        $apiSiteParameter,
30
        $name,
31
        $relation,
32
        $siteUrl
33
    ) {
34
        $instance = new self();
35
        $instance
36
            ->setApiSiteParameter($apiSiteParameter)
37
            ->setName($name)
38
            ->setRelation($relation)
39
            ->setSiteUrl($siteUrl);
40
41
        return $instance;
42
    }
43
44
    public static function fromJson(array $data)
45
    {
46
        $instance = new self();
47
        $instance
48
            ->setApiSiteParameter(array_key_exists('api_site_parameter', $data) ? $data['api_site_parameter'] : null)
49
            ->setName(array_key_exists('name', $data) ? $data['name'] : null)
50
            ->setName(array_key_exists('relation', $data) ? $data['relation'] : null)
51
            ->setName(array_key_exists('site_url', $data) ? $data['site_url'] : null);
52
53
        return $instance;
54
    }
55
56
57
    public function setApiSiteParameter($apiSiteParameter)
58
    {
59
        $this->apiSiteParameter = $apiSiteParameter;
60
61
        return $this;
62
    }
63
64
    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...
65
    {
66
        return $this->apiSiteParameter;
67
    }
68
69
    public function setName($name)
70
    {
71
        $this->name = $name;
72
73
        return $this;
74
    }
75
76
    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...
77
    {
78
        return $this->name;
79
    }
80
81
    public function setRelation($relation)
82
    {
83
        if (in_array($relation, self::RELATIONS, true)) {
84
            $this->relation = $relation;
85
        }
86
87
        return $this;
88
    }
89
90
    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...
91
    {
92
        return $this->relation;
93
    }
94
95
    public function setSiteUrl($siteUrl)
96
    {
97
        $this->siteUrl = $siteUrl;
98
99
        return $this;
100
    }
101
102
    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...
103
    {
104
        return $this->siteUrl;
105
    }
106
}
107