Completed
Pull Request — master (#2)
by Márk
02:43
created

DiactorosUriFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUri() 0 10 3
1
<?php
2
3
namespace Http\Message\UriFactory;
4
5
use Http\Message\UriFactory;
6
use Psr\Http\Message\UriInterface;
7
use Zend\Diactoros\Uri;
8
9
/**
10
 * Creates Diactoros URI.
11
 *
12
 * @author David de Boer <[email protected]>
13
 */
14
final class DiactorosUriFactory implements UriFactory
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 3
    public function createUri($uri)
20
    {
21 3
        if ($uri instanceof UriInterface) {
22 1
            return $uri;
23 2
        } elseif (is_string($uri)) {
24 1
            return new Uri($uri);
25
        }
26
27 1
        throw new \InvalidArgumentException('URI must be a string or UriInterface');
28
    }
29
}
30