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;
 12: 
 13: use expect\matcher\ReportableMatcher;
 14: 
 15: /**
 16:  * Evaluate the matcher.
 17:  *
 18:  * @method boolean toEqual() toEqual(mixed $expected)
 19:  * @method boolean toBe() toBe(mixed $expected)
 20:  * @method boolean toBeTrue() toBeTrue()
 21:  * @method boolean toBeTruthy() toBeTruthy()
 22:  * @method boolean toBeFalse() toBeFalse()
 23:  * @method boolean toBeFalsy() toBeFalsy()
 24:  * @method boolean toBeNull() toBeNull()
 25:  * @method boolean toBeA() toBeA(string $expected)
 26:  * @method boolean toBeAn() toBeAn(string $expected)
 27:  * @method boolean toBeString() toBeString()
 28:  * @method boolean toBeInteger() toBeInteger()
 29:  * @method boolean toBeFloat() toBeFloat()
 30:  * @method boolean toBeBoolean() toBeBoolean()
 31:  * @method boolean toBeAnInstanceOf() toBeAnInstanceOf(string $expected)
 32:  * @method boolean toThrow() toThrow(string $expected)
 33:  * @method boolean toHaveLength() toHaveLength(integer $expected)
 34:  * @method boolean toBeEmpty() toBeEmpty()
 35:  * @method boolean toPrint() toPrint(string $expected)
 36:  * @method boolean toMatch() toMatch(string $expected)
 37:  * @method boolean toStartWith() toStartWith(string $expected)
 38:  * @method boolean toEndWith() toEndWith(string $expected)
 39:  * @method boolean toContain() toContain(string $expected)
 40:  * @method boolean toHaveKey() toHaveKey(string $expected)
 41:  * @method boolean toBeGreaterThan() toBeGreaterThan(integer $expected)
 42:  * @method boolean toBeLessThan() toBeLessThan(integer $expected)
 43:  * @method boolean toBeAbove() toBeAbove(integer $expected)
 44:  * @method boolean toBeBelow() toBeBelow(integer $expected)
 45:  * @method boolean toBeWithin() toBeWithin(integer $from, integer $to)
 46:  *
 47:  * @author Noritaka Horio <holy.shared.design@gmail.com>
 48:  * @copyright Noritaka Horio <holy.shared.design@gmail.com>
 49:  */
 50: class MatcherEvaluator implements Evaluator
 51: {
 52:     /**
 53:      * @var \expect\matcher\ReportableMatcher
 54:      */
 55:     private $matcher;
 56: 
 57:     /**
 58:      * @var bool
 59:      */
 60:     private $negated;
 61: 
 62:     /**
 63:      * Create a matcher evaluator.
 64:      *
 65:      * @param \expect\matcher\ReportableMatcher $matcher The use matcher
 66:      */
 67:     public function __construct(ReportableMatcher $matcher)
 68:     {
 69:         $this->negated = false;
 70:         $this->matcher = $matcher;
 71:     }
 72: 
 73:     /**
 74:      * Change state to nagative evaluation.
 75:      *
 76:      * @return MatcherEvaluator
 77:      */
 78:     public function negated()
 79:     {
 80:         $this->negated = true;
 81: 
 82:         return $this;
 83:     }
 84: 
 85:     /**
 86:      * Evaluate the value of actual.
 87:      *
 88:      * @param mixed $actual value of actual
 89:      *
 90:      * @return \expect\Result
 91:      */
 92:     public function evaluate($actual)
 93:     {
 94:         $matcherResult = $this->matcher->match($actual);
 95:         $expected = $this->negated ? false : true;
 96: 
 97:         $result = $matcherResult === $expected;
 98: 
 99:         return new Result($actual, $this->negated, $this->matcher, $result);
100:     }
101: 
102:     /**
103:      * {@inheritdoc}
104:      */
105:     public static function fromMatcher(ReportableMatcher $matcher)
106:     {
107:         return new self($matcher);
108:     }
109: }
110: 
Expect API documentation generated by ApiGen