Completed
Pull Request — master (#133)
by Damian
20:49 queued 18:16
created

AbstractValue::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2.0625
1
<?php
2
3
namespace Kaliop\eZMigrationBundle\API\Value;
4
5
use eZ\Publish\API\Repository\Exceptions\PropertyNotFoundException;
6
7
abstract class AbstractValue
8
{
9
    /**
10
     * Magic get function handling read to non public properties
11
     *
12
     * Returns value for all readonly (protected) properties.
13
     *
14
     * @ignore This method is for internal use
15
     * @access private
16
     *
17
     * @throws \eZ\Publish\API\Repository\Exceptions\PropertyNotFoundException exception on all reads to undefined properties so typos are not silently accepted.
18
     *
19
     * @param string $property Name of the property
20
     *
21
     * @return mixed
22
     */
23 71
    public function __get($property)
24
    {
25 71
        if (property_exists($this, $property))
26
        {
27 71
            return $this->$property;
28
        }
29
        throw new PropertyNotFoundException($property, get_class($this));
30
    }
31
32
    /**
33
     * Magic isset function handling isset() to non public properties
34
     *
35
     * Returns true for all (public/)protected/private properties.
36
     *
37
     * @ignore This method is for internal use
38
     * @access private
39
     *
40
     * @param string $property Name of the property
41
     *
42
     * @return boolean
43
     */
44 24
    public function __isset($property)
45
    {
46 24
        return property_exists($this, $property);
47
    }
48
}
49