ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DeriveTransformWithProblem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Refinery;
22
23use UnexpectedValueException;
24
31{
35
36 public function transform($from)
37 {
38 $this->check($from);
39 return $from;
40 }
41
42 public function check($value)
43 {
44 if (!$this->accepts($value)) {
45 throw new UnexpectedValueException($this->getErrorMessage($value));
46 }
47 }
48
49 public function problemWith($value): ?string
50 {
51 if (!$this->accepts($value)) {
52 return $this->getErrorMessage($value);
53 }
54
55 return null;
56 }
57}
trait DeriveTransformWithProblem
This trait is a convenience trait which uses DeriveApplyToFromTransform, DeriveInvokeFromTransform an...
getErrorMessage($value)