PHP Класс Webmozart\Expression\Expr

Use this class to build expressions:ons: php $expr = Expr::greaterThan(20)->orLessThan(10); You can evaluate the expression with another value {@link Expression::evaluate()}: php if ($expr->evaluate($value)) { do something... } You can also evaluate expressions by arrays by passing the array keys as second argument: php $expr = Expr::greaterThan(20, 'age') ->andStartsWith('Thomas', 'name'); $values = array( 'age' => 35, 'name' => 'Thomas Edison', ); if ($expr->evaluate($values)) { do something... }
С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
all ( Webmozart\Expression\Expression $expr ) : All Check that all entries of a traversable value match an expression.
andX ( array $conjuncts ) : AndX Create a conjunction.
atLeast ( integer $count, Webmozart\Expression\Expression $expr ) : AtLeast Check that at least N entries of a traversable value match an expression.
atMost ( integer $count, Webmozart\Expression\Expression $expr ) : AtMost Check that at most N entries of a traversable value match an expression.
contains ( string $string ) : Contains Check that a value contains a given string.
count ( Webmozart\Expression\Expression $expr ) : Count Check that the count of a collection matches an expression.
endsWith ( string $suffix ) : EndsWith Check that a value ends with a given string.
equals ( mixed $value ) : Equals Check that a value equals another value.
exactly ( integer $count, Webmozart\Expression\Expression $expr ) : Exactly Check that exactly N entries of a traversable value match an expression.
expr ( Webmozart\Expression\Expression $expr ) : Webmozart\Expression\Expression Returns the expression.
false ( ) : AlwaysFalse Always false (contradiction).
filter ( array | ArrayAcces\ArrayAccess | Traversabl\Traversable $collection, Webmozart\Expression\Expression $expr ) : array | ArrayAcces\ArrayAccess | Traversabl\Traversable Filter a collection for entries matching the expression.
greaterThan ( mixed $value ) : GreaterThan Check that a value is greater than another value.
greaterThanEqual ( mixed $value ) : GreaterThanEqual Check that a value is greater than or equal to another value.
in ( array $values ) : In Check that a value occurs in a list of values.
isEmpty ( ) : IsEmpty Check that a value is empty.
isInstanceOf ( string $className ) : IsEmpty Check that a value is an instance of a given class.
key ( string | integer $key, Webmozart\Expression\Expression $expr ) : Key Check that the value of an array key matches an expression.
keyExists ( string $keyName ) : KeyExists Check that a value key exists.
keyNotExists ( string $keyName ) : KeyNotExists Check that a value key does not exist.
lessThan ( mixed $value ) : LessThan Check that a value is less than another value.
lessThanEqual ( mixed $value ) : LessThanEqual Check that a value is less than or equal to another value.
matches ( string $regExp ) : Matches Check that a value matches a regular expression.
method ( string $methodName, $args ) : Method Check that the result of a method call matches an expression.
not ( Webmozart\Expression\Expression $expr ) : Webmozart\Expression\Logic\Not Negate an expression.
notEmpty ( ) : Webmozart\Expression\Logic\Not Check that a value is not empty.
notEquals ( mixed $value ) : NotEquals Check that a value does not equal another value.
notNull ( ) : NotSame Check that a value is not null.
notSame ( mixed $value ) : NotSame Check that a value is not identical to another value.
null ( ) : Same Check that a value is null.
orX ( array $disjuncts ) : OrX Create a disjunction.
property ( string $propertyName, Webmozart\Expression\Expression $expr ) : Method Check that the value of a property matches an expression.
same ( mixed $value ) : Same Check that a value is identical to another value.
startsWith ( string $prefix ) : StartsWith Check that a value starts with a given string.
true ( ) : AlwaysTrue Always true (tautology).

Приватные методы

Метод Описание
__construct ( ) This class cannot be instantiated.

Описание методов

all() публичный статический Метод

Check that all entries of a traversable value match an expression.
public static all ( Webmozart\Expression\Expression $expr ) : All
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\All The created expression.

andX() публичный статический Метод

Create a conjunction.
public static andX ( array $conjuncts ) : AndX
$conjuncts array The conjuncts.
Результат Webmozart\Expression\Logic\AndX The created conjunction.

atLeast() публичный статический Метод

Check that at least N entries of a traversable value match an expression.
public static atLeast ( integer $count, Webmozart\Expression\Expression $expr ) : AtLeast
$count integer The minimum number of entries that need to match.
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\AtLeast The created expression.

atMost() публичный статический Метод

Check that at most N entries of a traversable value match an expression.
public static atMost ( integer $count, Webmozart\Expression\Expression $expr ) : AtMost
$count integer The maximum number of entries that need to match.
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\AtMost The created expression.

contains() публичный статический Метод

Check that a value contains a given string.
public static contains ( string $string ) : Contains
$string string The sub-string.
Результат Webmozart\Expression\Constraint\Contains The created expression.

count() публичный статический Метод

Check that the count of a collection matches an expression.
public static count ( Webmozart\Expression\Expression $expr ) : Count
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\Count The created expression.

endsWith() публичный статический Метод

Check that a value ends with a given string.
public static endsWith ( string $suffix ) : EndsWith
$suffix string The suffix string.
Результат Webmozart\Expression\Constraint\EndsWith The created expression.

equals() публичный статический Метод

Check that a value equals another value.
public static equals ( mixed $value ) : Equals
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\Equals The created expression.

exactly() публичный статический Метод

Check that exactly N entries of a traversable value match an expression.
public static exactly ( integer $count, Webmozart\Expression\Expression $expr ) : Exactly
$count integer The number of entries that need to match.
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\Exactly The created expression.

expr() публичный статический Метод

Facilitates usage of expressions on PHP < 7.
public static expr ( Webmozart\Expression\Expression $expr ) : Webmozart\Expression\Expression
$expr Webmozart\Expression\Expression An expression.
Результат Webmozart\Expression\Expression The expression.

false() публичный статический Метод

Always false (contradiction).
public static false ( ) : AlwaysFalse
Результат Webmozart\Expression\Logic\AlwaysFalse The created expression.

filter() публичный статический Метод

Filter a collection for entries matching the expression.
public static filter ( array | ArrayAcces\ArrayAccess | Traversabl\Traversable $collection, Webmozart\Expression\Expression $expr ) : array | ArrayAcces\ArrayAccess | Traversabl\Traversable
$collection array | ArrayAcces\ArrayAccess | Traversabl\Traversable An array or an object implementing Traversable and ArrayAccess.
$expr Webmozart\Expression\Expression The expression to evaluate for each entry.
Результат array | ArrayAcces\ArrayAccess | Traversabl\Traversable The filtered collection.

greaterThan() публичный статический Метод

Check that a value is greater than another value.
public static greaterThan ( mixed $value ) : GreaterThan
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\GreaterThan The created expression.

greaterThanEqual() публичный статический Метод

Check that a value is greater than or equal to another value.
public static greaterThanEqual ( mixed $value ) : GreaterThanEqual
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\GreaterThanEqual The created expression.

in() публичный статический Метод

Check that a value occurs in a list of values.
public static in ( array $values ) : In
$values array The compared values.
Результат Webmozart\Expression\Constraint\In The created expression.

isEmpty() публичный статический Метод

Check that a value is empty.
public static isEmpty ( ) : IsEmpty
Результат Webmozart\Expression\Constraint\IsEmpty The created expression.

isInstanceOf() публичный статический Метод

Check that a value is an instance of a given class.
public static isInstanceOf ( string $className ) : IsEmpty
$className string The class name.
Результат Webmozart\Expression\Constraint\IsEmpty The created expression.

key() публичный статический Метод

Check that the value of an array key matches an expression.
public static key ( string | integer $key, Webmozart\Expression\Expression $expr ) : Key
$key string | integer The array key.
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\Key The created expression.

keyExists() публичный статический Метод

Check that a value key exists.
public static keyExists ( string $keyName ) : KeyExists
$keyName string The key name.
Результат Webmozart\Expression\Constraint\KeyExists The created expression.

keyNotExists() публичный статический Метод

Check that a value key does not exist.
public static keyNotExists ( string $keyName ) : KeyNotExists
$keyName string The key name.
Результат Webmozart\Expression\Constraint\KeyNotExists The created expression.

lessThan() публичный статический Метод

Check that a value is less than another value.
public static lessThan ( mixed $value ) : LessThan
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\LessThan The created expression.

lessThanEqual() публичный статический Метод

Check that a value is less than or equal to another value.
public static lessThanEqual ( mixed $value ) : LessThanEqual
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\LessThanEqual The created expression.

matches() публичный статический Метод

Check that a value matches a regular expression.
public static matches ( string $regExp ) : Matches
$regExp string The regular expression.
Результат Webmozart\Expression\Constraint\Matches The created expression.

method() публичный статический Метод

Check that the result of a method call matches an expression.
public static method ( string $methodName, $args ) : Method
$methodName string The name of the method to call.
Результат Webmozart\Expression\Selector\Method The created expression.

not() публичный статический Метод

Negate an expression.
public static not ( Webmozart\Expression\Expression $expr ) : Webmozart\Expression\Logic\Not
$expr Webmozart\Expression\Expression The negated expression.
Результат Webmozart\Expression\Logic\Not The created negation.

notEmpty() публичный статический Метод

Check that a value is not empty.
public static notEmpty ( ) : Webmozart\Expression\Logic\Not
Результат Webmozart\Expression\Logic\Not The created expression.

notEquals() публичный статический Метод

Check that a value does not equal another value.
public static notEquals ( mixed $value ) : NotEquals
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\NotEquals The created expression.

notNull() публичный статический Метод

Check that a value is not null.
public static notNull ( ) : NotSame
Результат Webmozart\Expression\Constraint\NotSame The created expression.

notSame() публичный статический Метод

Check that a value is not identical to another value.
public static notSame ( mixed $value ) : NotSame
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\NotSame The created expression.

null() публичный статический Метод

Check that a value is null.
public static null ( ) : Same
Результат Webmozart\Expression\Constraint\Same The created expression.

orX() публичный статический Метод

Create a disjunction.
public static orX ( array $disjuncts ) : OrX
$disjuncts array The disjuncts.
Результат Webmozart\Expression\Logic\OrX The created disjunction.

property() публичный статический Метод

Check that the value of a property matches an expression.
public static property ( string $propertyName, Webmozart\Expression\Expression $expr ) : Method
$propertyName string The name of the property.
$expr Webmozart\Expression\Expression The evaluated expression.
Результат Webmozart\Expression\Selector\Method The created expression.

same() публичный статический Метод

Check that a value is identical to another value.
public static same ( mixed $value ) : Same
$value mixed The compared value.
Результат Webmozart\Expression\Constraint\Same The created expression.

startsWith() публичный статический Метод

Check that a value starts with a given string.
public static startsWith ( string $prefix ) : StartsWith
$prefix string The prefix string.
Результат Webmozart\Expression\Constraint\StartsWith The created expression.

true() публичный статический Метод

Always true (tautology).
public static true ( ) : AlwaysTrue
Результат Webmozart\Expression\Logic\AlwaysTrue The created expression.