ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
DeriveTransformFromApplyTo.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8namespace ILIAS\Refinery;
9
11
13{
18 abstract public function applyTo(Result $result) : Result;
19
25 public function transform($from)
26 {
28 $result = $this->applyTo(new Result\Ok($from));
29 if (true === $result->isError()) {
30 $error = $result->error();
31
32 if ($error instanceof \Exception) {
33 throw $error;
34 }
35
36 throw new \Exception($error);
37 }
38 return $result->value();
39 }
40}
$result
An exception for terminatinating execution or to throw for unit testing.
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:14
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:12