ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
8namespace ILIAS\Refinery\URI;
9
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 }
45
46 return $result;
47 }
48
52 public function __invoke($from)
53 {
54 return $this->transform($from);
55 }
56}
$result
An exception for terminatinating execution or to throw for unit testing.
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
__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.
transform($from)
Perform the transformation.