You are here

trait Module in AmazonS3 7.2

Same name in this branch
  1. 7.2 tests/DrupalAdapter/Module.php \Drupal\amazons3Test\DrupalAdapter\Module
  2. 7.2 src/DrupalAdapter/Module.php \Drupal\amazons3\DrupalAdapter\Module

Stub for module.inc functions, with a call counter to log each call.

@class Module @package Drupal\amazons3Test\DrupalAdapter @codeCoverageIgnore

Hierarchy

  • trait \Drupal\amazons3Test\DrupalAdapter\Module
1 file declares its use of Module
CompositeFactory.php in tests/Stub/CompositeFactory.php

File

tests/DrupalAdapter/Module.php, line 12

Namespace

Drupal\amazons3Test\DrupalAdapter
View source
trait Module {
  protected $callCount = array();

  /**
   * @see module_invoke_all()
   * @param string $hook
   * @return array
   */
  public function module_invoke_all($hook) {
    $this
      ->logCall(__FUNCTION__ . ':' . $hook);
    return array();
  }

  /**
   * @see drupal_alter()
   * @param $type
   * @param $data
   * @param null $context1
   * @param null $context2
   * @param null $context3
   */
  public function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL) {
    $this
      ->logCall(__FUNCTION__ . ':' . $type);
  }

  /**
   * Log a function call.
   *
   * @param string $key
   *   A string with a function and any context data.
   */
  protected function logCall($key) {
    if (!isset($this->callCount[$key])) {
      $this->callCount[$key] = 0;
    }
    $this->callCount[$key]++;
  }

  /**
   * Get the call count for a given key.
   *
   * @param string $key
   *
   * @return int
   *   The number of times $key has been called.
   */
  public function getCallCount($key) {
    if (isset($this->callCount[$key])) {
      return $this->callCount[$key];
    }
    return 0;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Module::$callCount protected property
Module::drupal_alter public function
Module::getCallCount public function Get the call count for a given key.
Module::logCall protected function Log a function call.
Module::module_invoke_all public function