Overview

Namespaces

  • expect
    • config
    • configurator
    • context
    • factory
    • matcher
      • strategy
    • package
    • registry
    • reporter

Classes

  • expect\config\ConfigurationLoader
  • expect\config\DefaultConfiguration
  • expect\config\RuntimeConfiguration
  • expect\configurator\DefaultConfigurator
  • expect\configurator\FileConfigurator
  • expect\context\DefaultContextFactory
  • expect\context\EvaluateContext
  • expect\Dictionary
  • expect\Expect
  • expect\factory\DefaultMatcherFactory
  • expect\FailedMessage
  • expect\matcher\PatternMatcher
  • expect\matcher\strategy\ArrayInclusionStrategy
  • expect\matcher\strategy\InclusionResult
  • expect\matcher\strategy\StringInclusionStrategy
  • expect\matcher\ToBe
  • expect\matcher\ToBeA
  • expect\matcher\ToBeAbove
  • expect\matcher\ToBeAn
  • expect\matcher\ToBeAnInstanceOf
  • expect\matcher\ToBeArray
  • expect\matcher\ToBeBelow
  • expect\matcher\ToBeBoolean
  • expect\matcher\ToBeEmpty
  • expect\matcher\ToBeFalse
  • expect\matcher\ToBeFalsey
  • expect\matcher\ToBeFloat
  • expect\matcher\ToBeGreaterThan
  • expect\matcher\ToBeInteger
  • expect\matcher\ToBeLessThan
  • expect\matcher\ToBeNull
  • expect\matcher\ToBeString
  • expect\matcher\ToBeTrue
  • expect\matcher\ToBeTruthy
  • expect\matcher\ToBeWithin
  • expect\matcher\ToContain
  • expect\matcher\ToEndWith
  • expect\matcher\ToEqual
  • expect\matcher\ToHaveKey
  • expect\matcher\ToHaveLength
  • expect\matcher\ToMatch
  • expect\matcher\ToPrint
  • expect\matcher\ToStartWith
  • expect\matcher\ToThrow
  • expect\matcher\TruthyMatcher
  • expect\MatcherDictionary
  • expect\MatcherEvaluator
  • expect\MatcherPackage
  • expect\package\DefaultMatcherPackage
  • expect\package\DefaultPackageRegistrar
  • expect\package\MatcherClass
  • expect\package\ReflectionIterator
  • expect\registry\DefaultMatcherRegistry
  • expect\reporter\ExceptionReporter
  • expect\reporter\TextMessageReporter
  • expect\Result

Interfaces

  • expect\Configurable
  • expect\Configuration
  • expect\Configurator
  • expect\Context
  • expect\ContextFactory
  • expect\Evaluator
  • expect\Matcher
  • expect\matcher\ReportableMatcher
  • expect\matcher\strategy\InclusionStrategy
  • expect\MatcherContainer
  • expect\MatcherFactory
  • expect\MatcherRegistry
  • expect\Message
  • expect\PackageRegistrar
  • expect\RegisterablePackage
  • expect\ResultReporter

Traits

  • expect\config\ConfigurableConfiguration
  • expect\matcher\EqualMatcherDelegatable
  • expect\matcher\GreaterThanMatcherDelegatable
  • expect\matcher\LengthMatcherDelegatable
  • expect\matcher\LessThanMatcherDelegatable
  • expect\matcher\TypeMatcherDelegatable
  • expect\MatcherLookupTable

Exceptions

  • expect\config\ConfigurationFileNotFoundException
  • expect\config\NotAvailableException
  • expect\package\ComposerJsonNotFoundException
  • expect\registry\MatcherAlreadyRegisteredException
  • expect\registry\MatcherNotRegisteredException
  • expect\reporter\FailedException

Functions

  • expect\expect
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: /**
  4:  * This file is part of expect package.
  5:  *
  6:  * (c) Noritaka Horio <holy.shared.design@gmail.com>
  7:  *
  8:  * This source file is subject to the MIT license that is bundled
  9:  * with this source code in the file LICENSE.
 10:  */
 11: namespace expect\package;
 12: 
 13: use FilesystemIterator;
 14: use Iterator;
 15: use RecursiveDirectoryIterator;
 16: use RecursiveIteratorIterator;
 17: use ReflectionClass;
 18: use SplFileInfo;
 19: 
 20: class ReflectionIterator implements Iterator
 21: {
 22:     private $iterator;
 23:     private $namespace;
 24:     private $namespaceDirectory;
 25: 
 26:     /**
 27:      * @param string $namespace
 28:      * @param string $namespaceDirectory
 29:      */
 30:     public function __construct($namespace, $namespaceDirectory)
 31:     {
 32:         $this->namespace = $namespace;
 33:         $this->namespaceDirectory = $namespaceDirectory;
 34:         $this->iterator = $this->createIterator($this->namespaceDirectory);
 35:     }
 36: 
 37:     /**
 38:      * @return \expect\package\MatcherClass
 39:      */
 40:     public function current()
 41:     {
 42:         $classFile = $this->iterator->current();
 43:         $className = $this->getClassFullNameFromFile($classFile);
 44: 
 45:         return new ReflectionClass($className);
 46:     }
 47: 
 48:     public function key()
 49:     {
 50:         return realpath($this->iterator->key());
 51:     }
 52: 
 53:     public function next()
 54:     {
 55:         $this->iterator->next();
 56:     }
 57: 
 58:     public function rewind()
 59:     {
 60:         $this->iterator->rewind();
 61:     }
 62: 
 63:     public function valid()
 64:     {
 65:         return $this->iterator->valid();
 66:     }
 67: 
 68:     /**
 69:      * @param SplFileInfo $file
 70:      *
 71:      * @return mixed
 72:      */
 73:     private function getClassFullNameFromFile(SplFileInfo $file)
 74:     {
 75:         $targets = [
 76:             realpath($this->namespaceDirectory).'/',
 77:             '.php',
 78:         ];
 79: 
 80:         $replaceValues = ['', ''];
 81: 
 82:         $className = str_replace($targets, $replaceValues, realpath($file->getPathname()));
 83:         $className = str_replace('/', "\\", $className);
 84: 
 85:         return $this->namespace."\\".$className;
 86:     }
 87: 
 88:     /**
 89:      * @param string $directory
 90:      *
 91:      * @return RecursiveIteratorIterator
 92:      */
 93:     private function createIterator($directory)
 94:     {
 95:         $directoryIterator = new RecursiveDirectoryIterator($directory,
 96:             FilesystemIterator::CURRENT_AS_FILEINFO |
 97:             FilesystemIterator::KEY_AS_PATHNAME |
 98:             FilesystemIterator::SKIP_DOTS
 99:         );
100: 
101:         $filterIterator = new RecursiveIteratorIterator($directoryIterator,
102:             RecursiveIteratorIterator::LEAVES_ONLY);
103: 
104:         return $filterIterator;
105:     }
106: }
107: 
Expect API documentation generated by ApiGen