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

BaseAnnotation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 46
ccs 0
cts 18
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A __get() 0 6 1
A __set() 0 6 1
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