ILIAS  release_7 Revision v7.30-3-g800a261c036
NewMethodTransformation.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
5
11
16
18{
21
25 private $object;
26
30 private $method;
31
36 public function __construct(object $object, string $methodToCall)
37 {
38 if (false === method_exists($object, $methodToCall)) {
39 throw new \InvalidArgumentException(
40 'The second parameter MUST be an method of the object'
41 );
42 }
43
44 $this->object = $object;
45 $this->method = $methodToCall;
46 }
47
52 public function transform($from)
53 {
54 if (false === is_array($from)) {
55 $from = array($from);
56 }
57
58 return call_user_func_array(array($this->object, $this->method), $from);
59 }
60}
An exception for terminatinating execution or to throw for unit testing.
transform($from)
Perform the transformation.Please use this for transformations. It's more performant than calling inv...
A transformation is a function from one datatype to another.