-
Notifications
You must be signed in to change notification settings - Fork 1
List of available predicates
Wraps a predicate evaluation into a callable.
Predicate to test that something is contained. This predicate works with any scalar value:
$contains = new Contains(true);
$contains->test($value); // evaluates to true if $value contains something `true`
$contains = new Contains('foo');
$contains->test($value); // evaluates to true if $value is equal to foo or a string containing the phrase foo
Predicate to test that something is equal. It can compare any scalar value with an expected value. The value to test has to be of the same type and must have the same content as the expected value in order for the predicate to evaluate to true
.
$equals = new Equals(303);
$equals->test($value); // evaluates to true if $value contains the integer 303
Predicate to test that a string denotes an existing directory.
$isExistingDirectory = new IsExistingDirectory('/path/where/relatives/must/reside');
$isExistingDirectory->test('foo'); // evaluates to true if the path /path/where/relatives/must/reside/foo exists and is a directory
$isExistingDirectory->test('/path/to/foo'); // evaluates to true if the path /path/where/relatives/must/reside/path/to/foo exists and is a directory
In case no base directory is specified both global and relative pathes can be evaluated:
$isExistingDirectory = new IsExistingDirectory();
$isExistingDirectory->test('/path/to/foo'); // evaluates to true if the path /path/to/foo exists and is a directory
$isExistingDirectory->test('foo'); // evaluates to true if the path getcwd() . '/foo' exists and is a directory
Predicate to test that a string denotes an existing file.
$isExistingFile = new IsExistingFile('/path/where/relatives/must/reside');
$isExistingFile->test('foo.txt'); // evaluates to true if the path /path/where/relatives/must/reside/foo.txt exists and is a file
$isExistingFile->test('/path/to/foo.txt'); // evaluates to true if the path /path/where/relatives/must/reside/path/to/foo.txt exists and is a file
In case no base directory is specified both global and relative pathes can be evaluated:
$isExistingFile = new IsExistingFile();
$isExistingFile->test('/path/to/foo.txt'); // evaluates to true if the path /path/to/foo.txt exists and is a file
$isExistingFile->test('foo.txt'); // evaluates to true if the path getcwd() . '/foo.txt' exists and is a file
Predicate to test that a string is an existing http uri, i.e. has a DNS record.
Predicate to test that a string is a http uri. Does a syntactical check only, to ensure that the HTTP uri really exists use IsExistingHttpUri
instead (see above).
Predicate to test that something is an IP address, either v4 or v6.
Predicate to test that something is an IPv4 address.
Predicate to test that something is an IPv6 address.
Predicate to test that a string is a mail address.
Predicate to test a value against a list of allowed values.
Predicate to ensure a value complies to a given regular expression. The predicate uses preg_match()
and checks if the value occurs exactly one time. Please make sure that the supplied regular expression contains correct delimiters, they will not be applied automatically. The test()
method throws a stubbles\lang\exception\RuntimeException
in case the regular expression is invalid.