ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Constraint.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Refinery;
22 
25 
31 interface Constraint extends Transformation
32 {
42  public function check($value);
43 
50  public function accepts($value): bool;
51 
60  public function problemWith($value): ?string;
61 
72  public function applyTo(Result $result): Result;
73 
87  public function withProblemBuilder(callable $builder): self;
88 }
problemWith($value)
Tells what the problem with the provided value is.
withProblemBuilder(callable $builder)
Get a constraint like this one with a builder for a custom error message.
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
applyTo(Result $result)
Restricts a Result.
accepts($value)
Tells if the provided value complies.
check($value)
Checks the provided value.
A transformation is a function from one datatype to another.