Annotation::__set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Doctrine\Common\Annotations;
4
5
/**
6
 * Annotations class.
7
 *
8
 * @author Benjamin Eberlei <[email protected]>
9
 * @author Guilherme Blanco <[email protected]>
10
 * @author Jonathan Wage <[email protected]>
11
 * @author Roman Borschel <[email protected]>
12
 */
13
class Annotation
14
{
15
    /**
16
     * Value property. Common among all derived classes.
17
     *
18
     * @var mixed
19
     */
20
    public $value;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param array $data Key-value for properties to be defined in this class.
26
     */
27
    public final function __construct(array $data)
28
    {
29
        foreach ($data as $key => $value) {
30
            $this->$key = $value;
31
        }
32
    }
33
34
    /**
35
     * Error handler for unknown property accessor in Annotation class.
36
     *
37
     * @param string $name Unknown property name.
38
     *
39
     * @throws \BadMethodCallException
40
     */
41
    public function __get($name)
42
    {
43
        throw new \BadMethodCallException(
44
            sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
45
        );
46
    }
47
48
    /**
49
     * Error handler for unknown property mutator in Annotation class.
50
     *
51
     * @param string $name  Unknown property name.
52
     * @param mixed  $value Property value.
53
     *
54
     * @throws \BadMethodCallException
55
     */
56
    public function __set($name, $value)
57
    {
58
        throw new \BadMethodCallException(
59
            sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
60
        );
61
    }
62
}
63