11
11
12
12
namespace Eloquent \Enumeration ;
13
13
14
+ use Eloquent \Enumeration \Exception \ExtendsConcreteException ;
15
+ use Eloquent \Enumeration \Exception \UndefinedInstanceException ;
16
+ use Exception ;
17
+
14
18
/**
15
19
* Base class for Java style enumerations.
16
20
*/
@@ -38,7 +42,7 @@ public static final function multitonInstances()
38
42
* @param string $key The string key associated with the member instance.
39
43
*
40
44
* @return Multiton The member instance associated with the given string key.
41
- * @throws Exception\ UndefinedInstanceException If no associated instance is found.
45
+ * @throws UndefinedInstanceException If no associated instance is found.
42
46
*/
43
47
public static final function instanceByKey ($ key )
44
48
{
@@ -57,7 +61,7 @@ public static final function instanceByKey($key)
57
61
* @param mixed $value The value to match.
58
62
*
59
63
* @return Multiton The first member instance for which $instance->{$property}() === $value.
60
- * @throws Exception\ UndefinedInstanceException If no associated instance is found.
64
+ * @throws UndefinedInstanceException If no associated instance is found.
61
65
*/
62
66
public static final function instanceBy ($ property , $ value ) {
63
67
foreach (static ::multitonInstances () as $ instance ) {
@@ -75,7 +79,7 @@ public static final function instanceBy($property, $value) {
75
79
* @param callback $predicate The predicate applies to the multiton instance to find a match.
76
80
*
77
81
* @return Multiton The first member instance for which $predicate($instance) evaluates to boolean true.
78
- * @throws Exception\ UndefinedInstanceException If no associated instance is found.
82
+ * @throws UndefinedInstanceException If no associated instance is found.
79
83
*/
80
84
public static final function instanceByPredicate ($ predicate ) {
81
85
foreach (static ::multitonInstances () as $ instance ) {
@@ -94,7 +98,7 @@ public static final function instanceByPredicate($predicate) {
94
98
* @param array $arguments Ignored.
95
99
*
96
100
* @return Multiton The member instance associated with the given string key.
97
- * @throws Exception\ UndefinedInstanceException If no associated instance is found.
101
+ * @throws UndefinedInstanceException If no associated instance is found.
98
102
*/
99
103
public static final function __callStatic ($ key , array $ arguments )
100
104
{
@@ -142,15 +146,15 @@ protected static function initializeMultiton() {}
142
146
* @param mixed $value
143
147
* @param Exception|null $previous
144
148
*
145
- * @return Exception\ UndefinedInstanceExceptionInterface
149
+ * @return UndefinedInstanceExceptionInterface
146
150
*/
147
151
protected static function createUndefinedInstanceException (
148
152
$ className ,
149
153
$ property ,
150
154
$ value ,
151
155
Exception $ previous = null
152
156
) {
153
- return new Exception \ UndefinedInstanceException ($ className , $ property , $ value , $ previous );
157
+ return new UndefinedInstanceException ($ className , $ property , $ value , $ previous );
154
158
}
155
159
156
160
/**
@@ -163,7 +167,7 @@ protected static function createUndefinedInstanceException(
163
167
*
164
168
* @param string $key The string key to associate with this member instance.
165
169
*
166
- * @throws Exception\ ExtendsConcreteException If the constructed instance has an invalid inheritance hierarchy.
170
+ * @throws ExtendsConcreteException If the constructed instance has an invalid inheritance hierarchy.
167
171
*/
168
172
protected function __construct ($ key )
169
173
{
@@ -180,14 +184,14 @@ protected function __construct($key)
180
184
* also handle registration of the instance.
181
185
*
182
186
* @param Multiton $instance The instance to register.
183
- * @throws Exception\ ExtendsConcreteException If the supplied instance has an invalid inheritance hierarchy.
187
+ * @throws ExtendsConcreteException If the supplied instance has an invalid inheritance hierarchy.
184
188
*/
185
189
private static function registerMultiton (self $ instance )
186
190
{
187
191
$ reflector = new \ReflectionObject ($ instance );
188
192
$ parentClass = $ reflector ->getParentClass ();
189
193
if (!$ parentClass ->isAbstract ()) {
190
- throw new Exception \ ExtendsConcreteException (
194
+ throw new ExtendsConcreteException (
191
195
get_class ($ instance )
192
196
, $ parentClass ->getName ()
193
197
);
0 commit comments