Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / ArrayIndexer.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/ArrayIndexer.php b/web/modules/contrib/drupalmoduleupgrader/src/ArrayIndexer.php
new file mode 100644 (file)
index 0000000..a08e0e1
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\drupalmoduleupgrader;
+
+abstract class ArrayIndexer extends IndexerBase {
+
+  protected $elements = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  final public function hasAny(array $keys) {
+    foreach ($keys as $key) {
+      if ($this->count($key)) {
+        return TRUE;
+      }
+    }
+    return FALSE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  final public function hasAll(array $keys) {
+    foreach ($keys as $key) {
+      if ($this->count($key) == 0) {
+        return FALSE;
+      }
+    }
+    return TRUE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  final public function get($key) {
+    return $this->elements[$key];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  final public function getMultiple(array $keys) {
+    $values = array();
+
+    foreach ($keys as $key) {
+      if (array_key_exists($key, $this->elements)) {
+        $values[$key] = $this->get($key);
+      }
+    }
+
+    return $values;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  final public function getAll() {
+    return $this->elements;
+  }
+
+}