Completed
Push — master ( 40e49a...c75a1a )
by François
02:05
created

Address::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
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 Bouncer package.
5
 *
6
 * (c) François Hodierne <[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 Bouncer\Resource;
13
14
use Bouncer\Bouncer;
15
use Bouncer\Resource;
16
17
class Address extends Resource
18
{
19
20
    protected $id;
21
22
    protected $value;
23
24
    protected $hostname;
25
26
    public function __construct($attributes = null)
27
    {
28
        if (is_string($attributes)) {
29
            $this->setValue($attributes);
30
        } elseif (is_array($attributes)) {
31
            parent::__construct($attributes);
32
        }
33
    }
34
35
    public function getId()
36
    {
37
        return $this->id;
38
    }
39
40
    public function setId($id)
41
    {
42
        $this->id = $id;
43
    }
44
45
    public function getValue()
46
    {
47
        return $this->value;
48
    }
49
50
    public function setValue($value)
51
    {
52
        $this->value = $value;
53
        $this->id = Bouncer::hash($this->value);
54
    }
55
56
    public function getHostname()
57
    {
58
        return $this->hostname;
59
    }
60
61
    public function setHostname($hostname)
62
    {
63
        $this->hostname = $hostname;
64
    }
65
66
    public function getReverse()
67
    {
68
        return $this->getAttribute('reverse');
69
    }
70
71
    public function getAsNumber()
72
    {
73
        return $this->getAttribute('as_number');
74
    }
75
76
    public function getNetworkName()
77
    {
78
        return $this->getAttribute('network_name');
79
    }
80
81
    public function getCountryCode()
82
    {
83
        return $this->getAttribute('country_code');
84
    }
85
86
    public function getFlags()
87
    {
88
        return $this->getAttribute('flags');
89
    }
90
91
}
92