Documentation

ValueComparisonTrait

Value comparison trait

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
5.0.0

Table of Contents

Methods

containsMatch()  : bool
Determine if $needle is contained within $haystack (used by Contains/NotContains)
containsNoneMatch()  : bool
Determine if none of $needle is contained within $haystack (used by NotContains)
endsWithMatch()  : bool
Determine if $inputValue ends with $comparisonValue (used by EndsWith/NotEndsWith)
inMatch()  : bool
Determine if $needle is contained within $haystack (used by In/NotIn)
inNoneMatch()  : bool
Determine if none of $needle is contained within $haystack (used by NotIn)
resolveComparisonValueString()  : string
Resolve the comparison value string used in default messages (used by StartsWith/NotStartsWith/EndsWith/NotEndsWith)
resolveInputValue()  : mixed
Resolve the input value, honoring bracket key-field notation
startsWithMatch()  : bool
Determine if $inputValue starts with $comparisonValue (used by StartsWith/NotStartsWith)

Methods

containsMatch()

Determine if $needle is contained within $haystack (used by Contains/NotContains)

protected containsMatch(mixed $needle, mixed $haystack) : bool
Parameters
$needle : mixed
$haystack : mixed
Return values
bool

containsNoneMatch()

Determine if none of $needle is contained within $haystack (used by NotContains)

protected containsNoneMatch(mixed $needle, mixed $haystack) : bool

Note: not a simple boolean negation of containsMatch() — when $needle is an array compared against a scalar $haystack, this requires that none of $needle's elements are found (NOR), whereas containsMatch() requires that all of them are found (AND).

Parameters
$needle : mixed
$haystack : mixed
Return values
bool

endsWithMatch()

Determine if $inputValue ends with $comparisonValue (used by EndsWith/NotEndsWith)

protected endsWithMatch(mixed $inputValue, mixed $comparisonValue) : bool

An array $inputValue is never considered to "end with" anything, guarding against PHP silently coercing the array to the literal string "Array" and matching on that.

Parameters
$inputValue : mixed
$comparisonValue : mixed
Return values
bool

inMatch()

Determine if $needle is contained within $haystack (used by In/NotIn)

protected inMatch(mixed $needle, mixed $haystack) : bool
Parameters
$needle : mixed
$haystack : mixed
Return values
bool

inNoneMatch()

Determine if none of $needle is contained within $haystack (used by NotIn)

protected inNoneMatch(mixed $needle, mixed $haystack) : bool

Note: not a simple boolean negation of inMatch() — when $needle is an array compared against a scalar $haystack, this requires that none of $needle's elements are found (NOR), whereas inMatch() requires that all of them are found (AND).

Parameters
$needle : mixed
$haystack : mixed
Return values
bool

resolveComparisonValueString()

Resolve the comparison value string used in default messages (used by StartsWith/NotStartsWith/EndsWith/NotEndsWith)

protected resolveComparisonValueString(mixed $value) : string
Parameters
$value : mixed
Return values
string

resolveInputValue()

Resolve the input value, honoring bracket key-field notation

protected resolveInputValue() : mixed

startsWithMatch()

Determine if $inputValue starts with $comparisonValue (used by StartsWith/NotStartsWith)

protected startsWithMatch(mixed $inputValue, mixed $comparisonValue) : bool

An array $inputValue is never considered to "start with" anything, guarding against PHP silently coercing the array to the literal string "Array" and matching on that.

Parameters
$inputValue : mixed
$comparisonValue : mixed
Return values
bool

        
On this page

Search results