Overview

Namespaces

  • None
  • Peridot
    • Leo
      • Formatter
      • Interfaces
        • Assert
      • Matcher
        • Template
      • ObjectPath
      • Responder
  • PHP

Classes

  • AbstractMatcher
  • CountableMatcher
  • EmptyMatcher
  • EqualMatcher
  • ExceptionMatcher
  • GreaterThanMatcher
  • GreaterThanOrEqualMatcher
  • InclusionMatcher
  • InstanceofMatcher
  • KeysMatcher
  • LengthMatcher
  • LessThanMatcher
  • LessThanOrEqualMatcher
  • Match
  • NullMatcher
  • PatternMatcher
  • PredicateMatcher
  • PropertyMatcher
  • RangeMatcher
  • SameMatcher
  • SubStringMatcher
  • TrueMatcher
  • TruthyMatcher
  • TypeMatcher

Interfaces

  • MatcherInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class PropertyMatcher

PropertyMatcher determines if the actual array or object has the expected property, and optionally matches an expected value for that property.

Peridot\Leo\Matcher\AbstractMatcher implements Peridot\Leo\Matcher\MatcherInterface
Extended by Peridot\Leo\Matcher\PropertyMatcher
Namespace: Peridot\Leo\Matcher
Package: Peridot\Leo\Matcher
Located at Matcher/PropertyMatcher.php
Methods summary
public
# __construct( mixed $key, string $value = "" )

Parameters

$key
$value

Overrides

Peridot\Leo\Matcher\AbstractMatcher::__construct()
public integer|string
# getKey( )

Return the expected object or array key.

Return the expected object or array key.

Returns

integer|string
public mixed
# setKey( integer|string $key )

Set the expected object or array key.

Set the expected object or array key.

Parameters

$key

Returns

mixed
$this
public mixed
# getValue( )

Return the expected property value.

Return the expected property value.

Returns

mixed
public mixed
# setValue( mixed $value )

Set the expected property value.

Set the expected property value.

Parameters

$value

Returns

mixed
$this
public Peridot\Leo\Matcher\Template\TemplateInterface
# getDefaultTemplate( )

Return a default TemplateInterface if none was set.

Return a default TemplateInterface if none was set.

Returns

Peridot\Leo\Matcher\Template\TemplateInterface
public mixed
# getActualValue( )

Return the actual value given to the matcher.

Return the actual value given to the matcher.

Returns

mixed
public mixed
# setActualValue( mixed $actualValue )

Set the actual value given to the matcher. Used to store whether or not the actual value was set.

Set the actual value given to the matcher. Used to store whether or not the actual value was set.

Parameters

$actualValue

Returns

mixed
$this
public boolean
# isActualValueSet( )

Return if the actual value has been set.

Return if the actual value has been set.

Returns

boolean
public
# setIsDeep( mixed $isDeep )

Tell the property matcher to match deep properties.

Tell the property matcher to match deep properties.

return $this

public boolean
# isDeep( )

Return whether or not the matcher is matching deep properties.

Return whether or not the matcher is matching deep properties.

Returns

boolean
protected mixed
# doMatch( mixed $actual )

Matches if the actual value has a property, optionally matching the expected value of that property. If the deep flag is set, the matcher will use the ObjectPath utility to parse deep expressions.

Matches if the actual value has a property, optionally matching the expected value of that property. If the deep flag is set, the matcher will use the ObjectPath utility to parse deep expressions.

Parameters

$actual

Returns

mixed

Code

$this->doMatch('child->name->first', 'brian');

Endcode

protected array|object
# actualToArray( object|array $actual )

Convert the actual value to an array, whether it is an object or an array.

Convert the actual value to an array, whether it is an object or an array.

Parameters

$actual

Returns

array|object
protected boolean
# matchArrayIndex( mixed $actual )

Match that an array index exists, and matches the expected value if set.

Match that an array index exists, and matches the expected value if set.

Parameters

$actual

Returns

boolean
protected boolean
# matchDeep( mixed $actual )

Uses ObjectPath to parse an expression if the deep flag is set.

Uses ObjectPath to parse an expression if the deep flag is set.

Parameters

$actual

Returns

boolean
protected boolean
# isExpected( mixed $value )

Check if the given value is expected.

Check if the given value is expected.

Parameters

$value

Returns

boolean
protected
# validateActual( mixed $actual )

Ensure that the actual value is an object or an array.

Ensure that the actual value is an object or an array.

Parameters

$actual
protected array
# getTemplateStrings( )

Returns the strings used in creating the template for the matcher.

Returns the strings used in creating the template for the matcher.

Returns

array
Methods inherited from Peridot\Leo\Matcher\AbstractMatcher
getTemplate(), invert(), isNegated(), match(), setAssertion(), setTemplate()
Properties summary
protected string|integer $key
#
protected mixed $value
#
protected mixed $actualValue
#
protected boolean $actualValueSet
# false
protected boolean $isDeep
# false
Properties inherited from Peridot\Leo\Matcher\AbstractMatcher
$assertion, $expected, $negated, $template
Leo API documentation generated by ApiGen