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

Event::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace EveryPolitician\EveryPoliticianPopolo\Objects;
4
5
class Event extends PopoloObject
6
{
7
    protected $properties = [
8
        'id',
9
        'name',
10
        'classification',
11
        'startDate',
12
        'endDate',
13
        'organizationId',
14
        'organization',
15
        'identifiers',
16
        'current',
17
    ];
18
19 6
    public function __toString()
20
    {
21 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...
22
    }
23
24 42
    protected function getId()
25
    {
26 42
        return $this->arrGet($this->data, 'id');
27
    }
28
29 9
    protected function getName()
30
    {
31 9
        return $this->arrGet($this->data, 'name');
32
    }
33
34 3
    protected function getClassification()
35
    {
36 3
        return $this->arrGet($this->data, 'classification');
37
    }
38
39 12
    protected function getStartDate()
40
    {
41
        // TODO: Mark uses his magical ApproxDate.PAST here
42 12
        return $this->getDate('start_date', null);
43
    }
44
45 9
    protected function getEndDate()
46
    {
47
        // TODO: Mark uses his magical ApproxDate.FUTURE here
48 9
        return $this->getDate('end_date', null);
49
    }
50
51 6
    protected function getOrganizationId()
52
    {
53 6
        return $this->arrGet($this->data, 'organization_id');
54
    }
55
56 3
    protected function getOrganization()
57
    {
58 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...
59
    }
60
61 3
    protected function getIdentifiers()
62
    {
63 3
        return $this->getRelatedObjectArr('identifiers');
64
    }
65
66
    protected function getCurrent()
67
    {
68
        return $this->currentAt(new \DateTime);
69
    }
70
71 9
    public function currentAt($when)
72
    {
73 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...
74
    }
75
}
76