ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
StringTransformation.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 namespace ILIAS\Refinery\URI;
9 
10 use ILIAS\Data\URI;
14 
16 {
18 
22  public function transform($from)
23  {
24  if (false === $from instanceof URI) {
26  sprintf('The value MUST be of type "%s"', URI::class),
27  'not_uri_object'
28  );
29  }
30 
32  $result = $from->getBaseURI();
33 
34  $query = $from->getQuery();
35  if (null !== $query) {
36  $query = '?' . $query;
37  }
38  $result .= $query;
39 
40  $fragment = $from->getFragment();
41  if (null !== $fragment) {
42  $fragment = '#' . $fragment;
43  }
44  $result .= $fragment;
45 
46  return $result;
47  }
48 
52  public function __invoke($from)
53  {
54  return $this->transform($from);
55  }
56 }
$result
transform($from)
Perform the transformation.
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:17
__invoke($from)
Transformations should be callable.This MUST do the same as transform.
A transformation is a function from one datatype to another.