ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Constraint.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Refinery;
22
24use UnexpectedValueException;
25
31interface 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}
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
A constraint encodes some resrtictions on values.
Definition: Constraint.php:32
accepts($value)
Tells if the provided value complies.
applyTo(Result $result)
Restricts a Result.
check($value)
Checks the provided value.
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 transformation is a function from one datatype to another.