Failed Conditions
Push — type ( 257e93...5997a7 )
by Michael
02:15
created

Annotation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 47
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A __set() 0 4 1
A __get() 0 4 1
1
<?php
2
3
namespace Doctrine\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 39
    public final function __construct(array $data)
28
    {
29 39
        foreach ($data as $key => $value) {
30 25
            $this->$key = $value;
31
        }
32 39
    }
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 1
    public function __get($name)
42
    {
43 1
        throw new \BadMethodCallException(
44 1
            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 1
    public function __set($name, $value)
57
    {
58 1
        throw new \BadMethodCallException(
59 1
            sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
60
        );
61
    }
62
}
63