@@ -72,14 +72,10 @@ private static function createFbp(array $definition)
72
72
if (!empty ($ definition [self ::INITIALIZERS_LABEL ])) {
73
73
foreach ($ definition [self ::INITIALIZERS_LABEL ] as $ initializer ) {
74
74
if (empty ($ initializer [self ::DATA_LABEL ])) {
75
- throw new DumperException ("Defintion has " .
76
- self ::INITIALIZERS_LABEL . " but no " . self ::DATA_LABEL . " node "
77
- );
75
+ self ::throwDumperException ('no_definition ' , self ::DATA_LABEL );
78
76
}
79
77
if (empty ($ initializer [self ::TARGET_LABEL ])) {
80
- throw new DumperException ("Defintion has " .
81
- self ::INITIALIZERS_LABEL . " but no " . self ::TARGET_LABEL . " node "
82
- );
78
+ self ::throwDumperException ('no_definition ' , self ::TARGET_LABEL );
83
79
}
84
80
array_push (
85
81
$ fbp ,
@@ -134,7 +130,7 @@ private static function examineProcess($type, array $processPart)
134
130
if (self ::hasElement ($ process , self ::$ processes , false )) {
135
131
$ meta = "( " . self ::$ processes [$ process ][self ::COMPONENT_LABEL ] . ") " ;
136
132
} else {
137
- throw new DumperException ( "{ $ process } is not defined in " . self ::PROCESSES_LABEL );
133
+ self ::throwDumperException ( ' process ' , $ process );
138
134
}
139
135
140
136
if (self ::SOURCE_LABEL == $ type ) {
@@ -156,7 +152,7 @@ private static function hasElement($needle, array $haystack, $triggerException =
156
152
{
157
153
if (empty ($ haystack [$ needle ])) {
158
154
if ($ triggerException ) {
159
- throw new DumperException ( " Element has no { $ needle}" );
155
+ self :: throwDumperException ( ' elmeent ' , $ needle );
160
156
} else {
161
157
return false ;
162
158
}
@@ -180,4 +176,21 @@ private static function connectPorts($sourcePort, $targetPort)
180
176
]
181
177
);
182
178
}
179
+
180
+ private static function throwDumperException ($ type , $ value )
181
+ {
182
+ switch ($ type ) {
183
+ case 'element ' :
184
+ throw new DumperException ("Element has no {$ value }" );
185
+ break ;
186
+ case 'process ' :
187
+ throw new DumperException ("{$ value } is not defined in " . self ::PROCESSES_LABEL );
188
+ break ;
189
+ case 'no_definition ' :
190
+ throw new DumperException ("Defintion has " .
191
+ self ::INITIALIZERS_LABEL . " but no {$ value } node "
192
+ );
193
+ break ;
194
+ }
195
+ }
183
196
}
0 commit comments