You are here

ArrayIndexer.php in Drupal 7 to 8/9 Module Upgrader 8

File

src/ArrayIndexer.php
View source
<?php

namespace Drupal\drupalmoduleupgrader;

abstract class ArrayIndexer extends IndexerBase {
  protected $elements = [];

  /**
   * {@inheritdoc}
   */
  public final function hasAny(array $keys) {
    foreach ($keys as $key) {
      if ($this
        ->count($key)) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public final function hasAll(array $keys) {
    foreach ($keys as $key) {
      if ($this
        ->count($key) == 0) {
        return FALSE;
      }
    }
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public final function get($key) {
    return $this->elements[$key];
  }

  /**
   * {@inheritdoc}
   */
  public final function getMultiple(array $keys) {
    $values = [];
    foreach ($keys as $key) {
      if (array_key_exists($key, $this->elements)) {
        $values[$key] = $this
          ->get($key);
      }
    }
    return $values;
  }

  /**
   * {@inheritdoc}
   */
  public final function getAll() {
    return $this->elements;
  }

}

Classes

Namesort descending Description
ArrayIndexer