+ /**
+ * Validates CSS library structure.
+ *
+ * @param array $library
+ * The library definition array.
+ *
+ * @return int
+ * Returns based on validity:
+ * - 0 if the library definition is valid
+ * - 1 if the library definition has improper nesting
+ * - 2 if the library definition specifies files as an array
+ */
+ public static function validateCssLibrary($library) {
+ $categories = [];
+ // Verify options first and return early if invalid.
+ foreach ($library as $category => $files) {
+ if (!is_array($files)) {
+ return 2;
+ }
+ $categories[] = $category;
+ foreach ($files as $source => $options) {
+ if (!is_array($options)) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+ }
+