ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Refinery\Constraint Interface Reference

A constraint encodes some resrtictions on values. More...

+ Inheritance diagram for ILIAS\Refinery\Constraint:
+ Collaboration diagram for ILIAS\Refinery\Constraint:

Public Member Functions

 check ($value)
 Checks the provided value. More...
 
 accepts ($value)
 Tells if the provided value complies. More...
 
 problemWith ($value)
 Tells what the problem with the provided value is. More...
 
 applyTo (Result $result)
 Restricts a Result. More...
 
 withProblemBuilder (callable $builder)
 Get a constraint like this one with a builder for a custom error message. More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 transform ($from)
 Perform the transformation. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Detailed Description

A constraint encodes some resrtictions on values.

Constraints MUST NOT modify the supplied value.

Definition at line 14 of file Constraint.php.

Member Function Documentation

◆ accepts()

ILIAS\Refinery\Constraint::accepts (   $value)

Tells if the provided value complies.

Parameters
mixed$value
Returns
bool

Implemented in ILIAS\Refinery\Custom\Constraint.

Referenced by LogicalOrTest\testAccept().

+ Here is the caller graph for this function:

◆ applyTo()

ILIAS\Refinery\Constraint::applyTo ( Result  $result)

Restricts a Result.

Must do nothing with the result if $result->isError(). Must replace the result with an error according to problemWith() if !accepts($result->value()).

Parameters
Result$result
Returns
Result

Implements ILIAS\Refinery\Transformation.

Implemented in ILIAS\Refinery\Custom\Constraint.

Referenced by LogicalOrTest\testRestrict().

+ Here is the caller graph for this function:

◆ check()

ILIAS\Refinery\Constraint::check (   $value)

Checks the provided value.

Should not throw if accepts($value).

Exceptions

Implemented in ILIAS\Refinery\Custom\Constraint.

Referenced by LogicalOrTest\testCheck().

+ Here is the caller graph for this function:

◆ problemWith()

ILIAS\Refinery\Constraint::problemWith (   $value)

Tells what the problem with the provided value is.

Should return null if accepts($value).

Parameters
mixed$value
Returns
string|null

Implemented in ILIAS\Refinery\Custom\Constraint.

Referenced by LogicalOrTest\testProblemWith().

+ Here is the caller graph for this function:

◆ withProblemBuilder()

ILIAS\Refinery\Constraint::withProblemBuilder ( callable  $builder)

Get a constraint like this one with a builder for a custom error message.

problemWith() must return an error message according to the new builder for the new constraint.

The builder needs to be callable that takes two parameters:

Parameters
callable$builder
Returns
Constraint

Referenced by LogicalOrTest\testWithProblemBuilder().

+ Here is the caller graph for this function:

The documentation for this interface was generated from the following file: