current_location()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace BenTools\UriFactory\Helper;
4
5
use BenTools\UriFactory\UriCanonicalizer;
6
use BenTools\UriFactory\UriFactory;
7
use BenTools\UriFactory\UriFactoryInterface;
8
use Psr\Http\Message\UriInterface;
9
10
/**
11
 * @param string $uri
12
 * @param UriFactoryInterface|null $factory
13
 * @return UriInterface
14
 */
15
function uri(string $uri, ?UriFactoryInterface $factory = null): UriInterface
16
{
17
    return UriFactory::factory()->createUri($uri, $factory);
18
}
19
20
/**
21
 * @param UriFactoryInterface|null $factory
22
 * @return UriInterface
23
 * @throws \RuntimeException
24
 */
25
function current_location(?UriFactoryInterface $factory = null): UriInterface
26
{
27
    return UriFactory::factory()->createUriFromCurrentLocation($factory);
28
}
29
30
/**
31
 * @param UriInterface $uri
32
 * @return UriInterface
33
 * @throws \InvalidArgumentException
34
 */
35
function canonicalize(UriInterface $uri): UriInterface
36
{
37
    return UriCanonicalizer::canonicalize($uri);
38
}
39