UriFactory::createUri()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 10
1
<?php
2
3
namespace DMT\Aura\Psr\Factory;
4
5
use DMT\Aura\Psr\Message\Uri;
6
use InvalidArgumentException;
7
use Psr\Http\Message\UriFactoryInterface;
8
use Psr\Http\Message\UriInterface;
9
10
/**
11
 * Class UriFactory
12
 *
13
 * @package DMT\Aura\Psr\Factory
14
 */
15
class UriFactory implements UriFactoryInterface
16
{
17
    /**
18
     * Create a new URI.
19
     *
20
     * @param string $uri
21
     * @return UriInterface
22
     * @throws InvalidArgumentException
23
     */
24 73
    public function createUri(string $uri = ''): UriInterface
25
    {
26 73
        if ($uri !== '' && parse_url($uri) === false) {
27 2
            throw new InvalidArgumentException('illegal uri given');
28
        }
29
30 71
        return new Uri($uri);
31
    }
32
}
33