You are here

abstract class AbstractInjectedApi in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/ClassFinder/InjectedApi/AbstractInjectedApi.php \Drupal\xautoload\ClassFinder\InjectedApi\AbstractInjectedApi

To help testability, we use an injected API instead of just a return value. The injected API can be mocked to provide a mocked file_exists(), and to monitor all suggested candidates, not just the correct return value.

Hierarchy

Expanded class hierarchy of AbstractInjectedApi

File

lib/ClassFinder/InjectedApi/AbstractInjectedApi.php, line 10

Namespace

Drupal\xautoload\ClassFinder\InjectedApi
View source
abstract class AbstractInjectedApi implements InjectedApiInterface {

  /**
   * @var string
   *   The class name to look for. Set in the constructor.
   */
  protected $className;

  /**
   * @param $class_name
   *   Name of the class or interface we are trying to load.
   */
  function __construct($class_name) {
    $this->className = $class_name;
  }

  /**
   * This is done in the injected api object, so we can easily provide a mock
   * implementation.
   */
  function is_dir($dir) {
    return is_dir($dir);
  }

  /**
   * Get the name of the class we are looking for.
   *
   * @return string
   *   The class we are looking for.
   */
  function getClass() {
    return $this->className;
  }

  /**
   * Dummy method to force autoloading this class (or an ancestor).
   */
  static function forceAutoload() {

    // Do nothing.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractInjectedApi::$className protected property The class name to look for. Set in the constructor.
AbstractInjectedApi::forceAutoload static function Dummy method to force autoloading this class (or an ancestor).
AbstractInjectedApi::getClass function Get the name of the class we are looking for. Overrides InjectedApiInterface::getClass
AbstractInjectedApi::is_dir function This is done in the injected api object, so we can easily provide a mock implementation. Overrides InjectedApiInterface::is_dir
AbstractInjectedApi::__construct function 1
InjectedApiInterface::claimFile function Suggest a file that MUST exist, and if so, MUST declare the class we are looking for. 3
InjectedApiInterface::claimPath function Suggest a file that MAY exist, and if so, MUST declare the class we are looking for. 3
InjectedApiInterface::guessFile function Suggest a file that MUST exists, and that MAY declare the class we are looking for. 3
InjectedApiInterface::guessPath function Suggest a file that MAY exist, and that MAY declare the class we are looking for. 3
InjectedApiInterface::suggestFile function Suggest a file that, if the file exists, has to declare the class we are looking for. Only keep the class on success. 3
InjectedApiInterface::suggestFile_checkIncludePath function Same as suggestFile(), but check the full PHP include path. 3
InjectedApiInterface::suggestFile_checkNothing function Same as suggestFile(), but assume that file_exists() returns TRUE. 3
InjectedApiInterface::suggestFile_skipFileExists function Same as suggestFile(), but skip the file_exists(), assuming that we already know the file exists. 3