1 | <?php |
||
14 | class State implements StateInterface |
||
15 | { |
||
16 | /** |
||
17 | * The state type. |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | protected $type; |
||
22 | |||
23 | /** |
||
24 | * The transition name. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $transitions; |
||
29 | |||
30 | /** |
||
31 | * The state name. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $name; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $properties; |
||
41 | |||
42 | 230 | public function __construct($name, $type = self::TYPE_NORMAL, array $transitions = array(), array $properties = array()) |
|
43 | { |
||
44 | 230 | $this->name = $name; |
|
45 | 230 | $this->type = $type; |
|
|
|||
46 | 230 | $this->transitions = $transitions; |
|
47 | 230 | $this->properties = $properties; |
|
48 | 230 | } |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function isInitial() |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function isFinal() |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function isNormal() |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | 20 | public function getType() |
|
81 | |||
82 | /** |
||
83 | * @param $transition |
||
84 | */ |
||
85 | 190 | public function addTransition($transition) |
|
93 | |||
94 | /** |
||
95 | * @param array $transitions |
||
96 | */ |
||
97 | public function setTransitions(array $transitions) |
||
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | 70 | public function getTransitions() |
|
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | * |
||
115 | * @deprecated Deprecated since version 1.0.0-BETA2. Use {@link StateMachine::can($transition)} instead. |
||
116 | */ |
||
117 | public function can($transition) |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | 20 | public function has($property) |
|
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | 5 | public function get($property, $default = null) |
|
138 | { |
||
139 | 5 | return $this->has($property) ? $this->properties[$property] : $default; |
|
140 | } |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | 10 | public function getProperties() |
|
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | 195 | public function getName() |
|
157 | |||
158 | /** |
||
159 | * @param array $properties |
||
160 | */ |
||
161 | public function setProperties(array $properties) |
||
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | public function __toString() |
||
173 | } |
||
174 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.