ILIAS  release_7 Revision v7.30-3-g800a261c036
DateTimeTransformation.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3
5
11
17{
20
24 private $factory;
25
29 public function __construct(Factory $factory)
30 {
31 $this->factory = $factory;
32 }
33
37 public function transform($from)
38 {
39 try {
40 return new \DateTimeImmutable($from);
41 } catch (\Exception $e) {
42 throw new \InvalidArgumentException($e->getMessage(), 1);
43 }
44 }
45}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
Transform a string representing a datetime-value to php's DateTimeImmutable see https://www....
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.