Ip::makeFromIpJson()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 1
nop 1
crap 3
1
<?php
2
3
namespace ChrisArmitage\ScalewayApi\Domain;
4
5
class Ip
6
{
7
    protected $id;
8
    protected $address;
9
10 2
    protected function __construct($id, $address) {
11 2
        $this->id = $id;
12 2
        $this->address = $address;
13 2
    }
14
15 1
    static public function makeFromIpJson($ipJson) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
16 1
        return new static(
17 1
            isset($ipJson->id) ? $ipJson->id : null,
18 1
            isset($ipJson->address) ? $ipJson->address : null
19 1
        );
20
    }
21
22 1
    static public function makeFromIpAddress($ipAddress) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
23 1
        return new static(null, $ipAddress);
24
    }
25
26
    /**
27
     * @return mixed
28
     */
29 2
    public function getId() {
30 2
        return $this->id;
31
    }
32
33
    /**
34
     * @return mixed
35
     */
36 2
    public function getAddress() {
37 2
        return $this->address;
38
    }
39
}