ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
10 
16 {
18 
22  private $factory;
23 
27  public function __construct(Factory $factory)
28  {
29  $this->factory = $factory;
30  }
31 
35  public function transform($from)
36  {
37  try {
38  return new \DateTimeImmutable($from);
39  } catch (\Exception $e) {
40  throw new \InvalidArgumentException($e->getMessage(), 1);
41  }
42  }
43 
47  public function __invoke($from)
48  {
49  return $this->transform($from);
50  }
51 }
__invoke($from)
Transformations should be callable.This MUST do the same as transform.
Builds data types.
Definition: Factory.php:19
Transform a string representing a datetime-value to php&#39;s DateTimeImmutable see https://www.php.net/manual/de/datetime.formats.php.
transform($from)
Perform the transformation.Please use this for transformations. It&#39;s more performant than calling inv...
A transformation is a function from one datatype to another.