Completed
Pull Request — master (#463)
by Alexander
30:17 queued 05:15
created

BaseAnnotation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 46
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 * Go! AOP framework
6
 *
7
 * @copyright Copyright 2012, Lisachenko Alexander <[email protected]>
8
 *
9
 * This source file is subject to the license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Go\Lang\Annotation;
14
15
use BadMethodCallException;
16
17
/**
18
 * @Annotation
19
 */
20
abstract class BaseAnnotation
21
{
22
    /**
23
     * Value property. Common among all derived classes.
24
     */
25
    public string $value;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
26
27
    /**
28
     * Constructor
29
     *
30
     * @param array $data Key-value for properties to be defined in this class
31 1
     */
32
    final public function __construct(array $data)
33 1
    {
34 1
        foreach ($data as $key => $value) {
35
            $this->$key = $value;
36 1
        }
37
    }
38
39
    /**
40
     * Error handler for unknown property accessor in Annotation class.
41
     */
42
    public function __get(string $name)
43
    {
44
        throw new BadMethodCallException(
45
            sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)
46
        );
47
    }
48
49
    /**
50
     * Error handler for unknown property mutator in Annotation class.
51
     *
52
     * @param mixed $value Property value
53
     */
54
    public function __set(string $name, $value)
55
    {
56
        throw new BadMethodCallException(
57
            sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)
58
        );
59
    }
60
}
61