Code Duplication    Length = 18-18 lines in 2 locations

src/PropertyTrait.php 2 locations

@@ 37-54 (lines=18) @@
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function __get($name)
38
    {
39
        if (self::$_annotations === null) {
40
            $this->parseAnnotations();
41
        }
42
43
        $access = self::$_annotations[$name] ?? null;
44
45
        if ($access !== 'property' && $access !== 'property-read') {
46
            throw new \InvalidArgumentException('Unknown read property: ' . $name);
47
        }
48
49
        $getters = $this->getters();
50
51
        return isset($getters[$name])
52
            ? $getters[$name]()
53
            : $this->$name;
54
    }
55
56
    /**
57
     * {@inheritdoc}
@@ 59-76 (lines=18) @@
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function __set($name, $value)
60
    {
61
        if (self::$_annotations === null) {
62
            $this->parseAnnotations();
63
        }
64
65
        $access = self::$_annotations[$name] ?? null;
66
67
        if ($access !== 'property' && $access !== 'property-write') {
68
            throw new \InvalidArgumentException('Unknown write property: ' . $name);
69
        }
70
71
        $setters = $this->setters();
72
73
        isset($setters[$name])
74
            ? $setters[$name]($value)
75
            : $this->$name = $value;
76
    }
77
78
    /**
79
     * Returns array of custom getters.