DiactorosUriFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A createUri() 0 13 4
1
<?php
2
3
namespace Http\Message\UriFactory;
4
5
use Http\Message\UriFactory;
6
use Laminas\Diactoros\Uri as LaminasUri;
7
use Psr\Http\Message\UriInterface;
8
use Zend\Diactoros\Uri as ZendUri;
0 ignored issues
show
Bug introduced by
The type Zend\Diactoros\Uri was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Creates Diactoros URI.
12
 *
13
 * @author David de Boer <[email protected]>
14
 *
15
 * @deprecated This will be removed in php-http/message2.0. Consider using the official Diactoros PSR-17 factory
16
 */
17
final class DiactorosUriFactory implements UriFactory
18
{
19 3
    /**
20
     * {@inheritdoc}
21 3
     */
22 1
    public function createUri($uri)
23 2
    {
24 1
        if ($uri instanceof UriInterface) {
25
            return $uri;
26
        } elseif (is_string($uri)) {
27 1
            if (class_exists(LaminasUri::class)) {
28
                return new LaminasUri($uri);
29
            }
30
31
            return new ZendUri($uri);
32
        }
33
34
        throw new \InvalidArgumentException('URI must be a string or UriInterface');
35
    }
36
}
37