Completed
Push — master ( 3dee16...2bf36e )
by Andy
02:57
created

Organization   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 73
c 0
b 0
f 0
ccs 24
cts 24
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A getWikidata() 0 4 1
A getClassification() 0 4 1
A getImage() 0 4 1
A getFoundingDate() 0 4 1
A getDissolutionDate() 0 4 1
A getSeats() 0 4 1
A getOtherNames() 0 4 1
A getIdentifiers() 0 4 1
A getLinks() 0 4 1
1
<?php
2
3
namespace EveryPolitician\EveryPoliticianPopolo\Objects;
4
5
class Organization extends PopoloObject
6
{
7
    protected $properties = [
8
        'id',
9
        'name',
10
        'wikidata',
11
        'classification',
12
        'image',
13
        'foundingDate',
14
        'dissolutionDate',
15
        'seats',
16
        'otherNames',
17
        'identifiers',
18
        'links',
19
    ];
20
21 3
    public function __toString()
22
    {
23 3
        return "<Organization: ".$this->name.">";
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<EveryPolitician\E...o\Objects\Organization>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
24
    }
25
26 48
    protected function getId()
27
    {
28 48
         return $this->arrGet($this->data, 'id');
29
    }
30
31 6
    protected function getName()
32
    {
33 6
         return $this->arrGet($this->data, 'name');
34
    }
35
36 6
    protected function getWikidata()
37
    {
38 6
        return $this->identifierValue('wikidata');
39
    }
40
41 3
    protected function getClassification()
42
    {
43 3
        return $this->arrGet($this->data, 'classification');
44
    }
45
46 3
    protected function getImage()
47
    {
48 3
        return $this->arrGet($this->data, 'image');
49
    }
50
51 3
    protected function getFoundingDate()
52
    {
53 3
        return $this->getDate('founding_date');
54
    }
55 3
    protected function getDissolutionDate()
56
    {
57 3
        return $this->getDate('dissolution_date');
58
    }
59 3
    protected function getSeats()
60
    {
61 3
        return $this->arrGet($this->data, 'seats');
62
    }
63 3
    protected function getOtherNames()
64
    {
65 3
        return $this->arrGet($this->data, 'other_names', []);
66
    }
67
68 3
    protected function getIdentifiers()
69
    {
70 3
         return $this->getRelatedObjectArr('identifiers');
71
    }
72
73 3
    protected function getLinks()
74
    {
75 3
        return $this->getRelatedObjectArr('links');
76
    }
77
}
78