Completed
Push — 1.x ( c183a4...05b51a )
by Alexander
8s
created

BaseAnnotation::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2012, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Lang\Annotation;
12
13
/**
14
 * @Annotation
15
 */
16
abstract class BaseAnnotation
17
{
18
    /**
19
     * Value property. Common among all derived classes.
20
     *
21
     * @var string
22
     */
23
    public $value;
24
25
    /**
26
     * Constructor
27
     *
28
     * @param array $data Key-value for properties to be defined in this class
29
     */
30
    final public function __construct(array $data)
31
    {
32
        foreach ($data as $key => $value) {
33
            $this->$key = $value;
34
        }
35
    }
36
37
    /**
38
     * Error handler for unknown property accessor in Annotation class.
39
     *
40
     * @param string $name Unknown property name
41
     */
42
    public function __get($name)
43
    {
44
        throw new \BadMethodCallException(
45
            sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
46
        );
47
    }
48
49
    /**
50
     * Error handler for unknown property mutator in Annotation class.
51
     *
52
     * @param string $name Unknown property name
53
     * @param mixed $value Property value
54
     */
55
    public function __set($name, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    {
57
        throw new \BadMethodCallException(
58
            sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
59
        );
60
    }
61
}
62