SlimUriFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 16
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUri() 0 11 3
1
<?php
2
3
namespace Http\Message\UriFactory;
4
5
use Http\Message\UriFactory;
6
use Psr\Http\Message\UriInterface;
7
use Slim\Http\Uri;
8
9
/**
10
 * Creates Slim 3 URI.
11
 *
12
 * @author Mika Tuupola <[email protected]>
13
 *
14
 * @deprecated This will be removed in php-http/message2.0. Consider using the official Slim PSR-17 factory
15
 */
16
final class SlimUriFactory implements UriFactory
17
{
18
    /**
19 4
     * {@inheritdoc}
20
     */
21 4
    public function createUri($uri)
22 1
    {
23
        if ($uri instanceof UriInterface) {
24
            return $uri;
25 3
        }
26 2
27
        if (is_string($uri)) {
28
            return Uri::createFromString($uri);
29 1
        }
30
31
        throw new \InvalidArgumentException('URI must be a string or UriInterface');
32
    }
33
}
34