Event   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 12
lcom 2
cbo 1
dl 0
loc 76
ccs 20
cts 22
cp 0.9091
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A getClassification() 0 4 1
A getStartDate() 0 5 1
A getEndDate() 0 5 1
A getOrganizationId() 0 4 1
A getOrganization() 0 4 1
A getIdentifiers() 0 4 1
A getCurrent() 0 4 1
A currentAt() 0 4 2
1
<?php
2
3
namespace EveryPolitician\EveryPoliticianPopolo\Objects;
4
5
use \DateTime;
6
7
class Event extends PopoloObject
8
{
9
    protected $properties = [
10
        'id',
11
        'name',
12
        'classification',
13
        'startDate',
14
        'endDate',
15
        'organizationId',
16
        'organization',
17
        'identifiers',
18
        'current',
19
    ];
20
21
    /**
22
     * String representation of {@link Event}
23
     *
24
     * @return string
25
     */
26 6
    public function __toString()
27
    {
28 6
        return "<Event: ".$this->name.">";
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<EveryPolitician\E...anPopolo\Objects\Event>. 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...
29
    }
30
31 42
    protected function getId()
32
    {
33 42
        return $this->arrGet($this->data, 'id');
34
    }
35
36 9
    protected function getName()
37
    {
38 9
        return $this->arrGet($this->data, 'name');
39
    }
40
41 3
    protected function getClassification()
42
    {
43 3
        return $this->arrGet($this->data, 'classification');
44
    }
45
46 12
    protected function getStartDate()
47
    {
48
        // TODO: Mark uses his magical ApproxDate.PAST here
49 12
        return $this->getDate('start_date', null);
50
    }
51
52 9
    protected function getEndDate()
53
    {
54
        // TODO: Mark uses his magical ApproxDate.FUTURE here
55 9
        return $this->getDate('end_date', null);
56
    }
57
58 6
    protected function getOrganizationId()
59
    {
60 6
        return $this->arrGet($this->data, 'organization_id');
61
    }
62
63 3
    protected function getOrganization()
64
    {
65 3
        return $this->allPopolo->organizations->lookupFromKey[$this->organizationId];
0 ignored issues
show
Documentation introduced by
The property organizationId does not exist on object<EveryPolitician\E...anPopolo\Objects\Event>. 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...
66
    }
67
68 3
    protected function getIdentifiers()
69
    {
70 3
        return $this->getRelatedObjectArr('identifiers');
71
    }
72
73
    protected function getCurrent()
74
    {
75
        return $this->currentAt(new DateTime);
76
    }
77
78 9
    public function currentAt($when)
79
    {
80 9
        return ($when >= $this->startDate && $when <= $this->endDate);
0 ignored issues
show
Documentation introduced by
The property startDate does not exist on object<EveryPolitician\E...anPopolo\Objects\Event>. 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...
Documentation introduced by
The property endDate does not exist on object<EveryPolitician\E...anPopolo\Objects\Event>. 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...
81
    }
82
}
83