ILIAS  release_7 Revision v7.30-3-g800a261c036
NewObjectTransformation.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10
13
15{
17
18 private $className;
19
23 public function __construct(string $className)
24 {
25 $this->className = $className;
26 }
27
32 public function transform($from)
33 {
34 $class = new \ReflectionClass($this->className);
35 $instance = $class->newInstanceArgs($from);
36
37 return $instance;
38 }
39
44 public function __invoke($from)
45 {
46 return $this->transform($from);
47 }
48}
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...
__invoke($from)
Transformations should be callable.This MUST do the same as transform.InvalidArgumentException if the...
A transformation is a function from one datatype to another.