@@ -63,12 +63,23 @@ protected static function validateConfiguration(array $config)
6363 throw new \InvalidArgumentException ('the extra.css-compiler setting must be an array of objects ' );
6464 }
6565
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 ' );
6980 }
7081
71- static ::validateOptions ( $ el );
82+ static ::validateMandatoryOptions ( $ option );
7283 }
7384
7485 return true ;
@@ -80,18 +91,49 @@ protected static function validateConfiguration(array $config)
8091 * @return bool
8192 * @throws \InvalidArgumentException
8293 */
83- protected static function validateOptions (array $ config )
94+ protected static function validateMandatoryOptions (array $ config )
8495 {
8596 foreach (static ::$ mandatoryOptions as $ option ) {
8697 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 ;
88108 }
89109 }
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! ' );
92123 }
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! ' );
95137 }
96138
97139 return true ;
0 commit comments