@@ -63,12 +63,23 @@ protected static function validateConfiguration(array $config)
63
63
throw new \InvalidArgumentException ('the extra.css-compiler setting must be an array of objects ' );
64
64
}
65
65
66
- foreach ($ config [static ::CONFIG_MAIN_KEY ] as $ index => $ el ) {
67
- if (!is_array ($ el )) {
68
- throw new \InvalidArgumentException ("the extra.css-compiler[ {$ index }]. " . static ::OPTION_KEY_INPUT . ' array ' );
66
+ return static ::validateOptions ($ config [static ::CONFIG_MAIN_KEY ]);
67
+ }
68
+
69
+ /**
70
+ * @param array $config
71
+ *
72
+ * @return bool
73
+ * @throws \InvalidArgumentException
74
+ */
75
+ protected static function validateOptions (array $ config )
76
+ {
77
+ foreach ($ config as $ option ) {
78
+ if (!is_array ($ option )) {
79
+ throw new \InvalidArgumentException ('extra. ' . static ::CONFIG_MAIN_KEY . "[]. " . static ::OPTION_KEY_INPUT . ' array ' );
69
80
}
70
81
71
- static ::validateOptions ( $ el );
82
+ static ::validateMandatoryOptions ( $ option );
72
83
}
73
84
74
85
return true ;
@@ -80,18 +91,49 @@ protected static function validateConfiguration(array $config)
80
91
* @return bool
81
92
* @throws \InvalidArgumentException
82
93
*/
83
- protected static function validateOptions (array $ config )
94
+ protected static function validateMandatoryOptions (array $ config )
84
95
{
85
96
foreach (static ::$ mandatoryOptions as $ option ) {
86
97
if (empty ($ config [$ option ])) {
87
- throw new \InvalidArgumentException ("The extra.css-compiler[]. {$ option } required! " );
98
+ throw new \InvalidArgumentException ('extra. ' . static ::CONFIG_MAIN_KEY . "[]. {$ option } is required! " );
99
+ }
100
+
101
+ switch ($ option ) {
102
+ case static ::OPTION_KEY_INPUT :
103
+ static ::validateIsArray ($ config [$ option ]);
104
+ break ;
105
+ case static ::OPTION_KEY_OUTPUT :
106
+ static ::validateIsString ($ config [$ option ]);
107
+ break ;
88
108
}
89
109
}
90
- if (!is_array ($ config [static ::OPTION_KEY_INPUT ])) {
91
- throw new \InvalidArgumentException ('The extra.css-compiler[]. ' . static ::OPTION_KEY_INPUT . ' should be array! ' );
110
+
111
+ return true ;
112
+ }
113
+
114
+ /**
115
+ * @param array $option
116
+ *
117
+ * @return bool
118
+ */
119
+ protected static function validateIsArray ($ option )
120
+ {
121
+ if (!is_array ($ option )) {
122
+ throw new \InvalidArgumentException ('extra. ' . static ::CONFIG_MAIN_KEY . '[] ' . static ::OPTION_KEY_INPUT . ' should be array! ' );
92
123
}
93
- if (!is_string ($ config [static ::OPTION_KEY_OUTPUT ])) {
94
- throw new \InvalidArgumentException ('The extra.css-compiler[]. ' . static ::OPTION_KEY_OUTPUT . ' should string! ' );
124
+
125
+ return true ;
126
+ }
127
+
128
+ /**
129
+ * @param string $option
130
+ *
131
+ * @return bool
132
+ */
133
+ protected static function validateIsString ($ option )
134
+ {
135
+ if (!is_string ($ option )) {
136
+ throw new \InvalidArgumentException ('extra. ' . static ::CONFIG_MAIN_KEY . '[] ' . static ::OPTION_KEY_OUTPUT . ' should string! ' );
95
137
}
96
138
97
139
return true ;
0 commit comments