ILIAS  release_8 Revision v8.23
DeriveApplyToFromTransform.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 namespace ILIAS\Refinery;
22 
26 use Exception;
27 
29 {
33  abstract public function transform($from);
34 
38  public function applyTo(Result $result): Result
39  {
40  return $result->then(function ($value): Result {
41  try {
42  return new Ok($this->transform($value));
43  } catch (Exception $exception) {
44  return new Error($exception);
45  }
46  });
47  }
48 }
then(callable $f)
Get a new result from the callable or do nothing if this is an error.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ByTrying.php:21
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:16