Completed
Push — master ( 20655c...87b69d )
by Jeroen
02:06
created

Address   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A createFromGoogleResult() 0 7 1
A getResult() 0 4 1
A getLabel() 0 4 1
1
<?php
2
3
namespace JeroenDesloovere\Geolocation\Result;
4
5
class Address
6
{
7
    /** @var \stdClass */
8
    private $result;
9
10
    /** @var null|string */
11
    private $label;
12
13
    private function __construct(
14
        \stdClass $result,
15
        ?string $label
16
    ) {
17
        $this->addressComponents = $result;
0 ignored issues
show
Bug introduced by
The property addressComponents does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
        $this->label = $label;
19
    }
20
21
    public static function createFromGoogleResult(\stdClass $result): Address
22
    {
23
        return new self(
24
            $result,
25
            $result->formatted_address ?? null
26
        );
27
    }
28
29
    public function getResult(): \stdClass
30
    {
31
        return $this->result;
32
    }
33
34
    public function getLabel(): ?string
35
    {
36
        return $this->label;
37
    }
38
}
39