PropertySetSchema   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 81
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPropertySchema() 0 9 2
A setPropertySchema() 0 10 2
A addPropertySchema() 0 7 1
A isRestricted() 0 4 1
A setRestricted() 0 6 1
1
<?php
2
/**
3
 * @link https://github.com/old-town/old-town-propertyset
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\PropertySet;
7
8
/**
9
 * Class PropertySetSchema
10
 *
11
 * @package OldTown\PropertySet
12
 */
13
class PropertySetSchema
14
{
15
    /**
16
     * @var PropertySchema[]
17
     */
18
    protected $propertySchemas = [];
19
20
    /**
21
     * @var bool
22
     */
23
    protected $restricted = false;
24
25
    /**
26
     *
27
     * @param string $key
28
     *
29
     * @return PropertySchema|null
30
     *
31
     */
32
    public function getPropertySchema($key)
33
    {
34
        $key = (string)$key;
35
        if (!array_key_exists($key, $this->propertySchemas)) {
36
            return null;
37
        }
38
39
        return $this->propertySchemas[$key];
40
    }
41
42
    /**
43
     *
44
     *
45
     * @param string $key
46
     * @param PropertySchema $ps
47
     *
48
     * @return $this
49
     */
50
    public function setPropertySchema($key, PropertySchema $ps)
51
    {
52
        $key = (string)$key;
53
        if (null !== $ps->getPropertyName()) {
54
            $ps->setPropertyName($key);
55
        }
56
        $this->propertySchemas[$key] = $ps;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @param PropertySchema $ps
63
     *
64
     * @return $this
65
     */
66
    public function addPropertySchema(PropertySchema $ps)
67
    {
68
        $key = (string)$ps->getPropertyName();
69
        $this->propertySchemas[$key] = $ps;
70
71
        return $this;
72
    }
73
74
    /**
75
     * @return boolean
76
     */
77
    public function isRestricted()
78
    {
79
        return $this->restricted;
80
    }
81
82
    /**
83
     * @param boolean $restricted
84
     *
85
     * @return $this
86
     */
87
    public function setRestricted($restricted)
88
    {
89
        $this->restricted = (boolean)$restricted;
90
91
        return $this;
92
    }
93
}
94