UriFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 9
Bugs 3 Features 0
Metric Value
eloc 4
c 9
b 3
f 0
dl 0
loc 17
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource;
6
7
use BEAR\Resource\Annotation\ContextScheme;
8
9
use function array_key_exists;
10
use function parse_url;
11
12
/** @psalm-import-type Query from Types */
13
final class UriFactory
14
{
15
    public function __construct(
16
        #[ContextScheme]
17
        private readonly string $schemaHost = 'page://self',
18
    ) {
19
    }
20
21
    /** @param Query $query */
0 ignored issues
show
Bug introduced by
The type BEAR\Resource\Query 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...
22
    public function __invoke(string $uri, array $query = []): Uri
23
    {
24
        $parsedUrl = (array) parse_url($uri);
25
        if (! array_key_exists('scheme', $parsedUrl)) {
26
            $uri = $this->schemaHost . $uri;
27
        }
28
29
        return new Uri($uri, $query);
30
    }
31
}
32