ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NewObjectTransformation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ReflectionClass;
26use ReflectionException;
27
29{
31
32 private string $className;
33
34 public function __construct(string $className)
35 {
36 $this->className = $className;
37 }
38
43 public function transform($from)
44 {
45 $class = new ReflectionClass($this->className);
46 $instance = $class->newInstanceArgs($from);
47
48 return $instance;
49 }
50
55 public function __invoke($from)
56 {
57 return $this->transform($from);
58 }
59}
A transformation is a function from one datatype to another.