Factory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource;
6
7
use BEAR\Resource\Exception\UriException;
8
use Override;
9
use Ray\Di\Di\Inject;
10
11
use function is_string;
12
13
final class Factory implements FactoryInterface
14
{
15
    public function __construct(
16
        private SchemeCollectionInterface $scheme,
17
        private readonly UriFactory $uri,
0 ignored issues
show
Bug introduced by
The type BEAR\Resource\UriFactory 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...
18
    ) {
19
    }
20
21
    /**
22
     * Set scheme collection
23
     *
24
     * @codeCoverageIgnore
25
     */
26
    #[Inject(optional: true)]
27
    public function setSchemeCollection(SchemeCollectionInterface $scheme): void
28
    {
29
        $this->scheme = $scheme;
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     *
35
     * @throws UriException
36
     */
37
    #[Override]
38
    public function newInstance($uri): ResourceObject
39
    {
40
        if (is_string($uri)) {
41
            $uri = ($this->uri)($uri);
42
        }
43
44
        $ro = $this->scheme->getAdapter($uri)->get($uri);
45
        $ro->uri = $uri;
46
47
        return $ro;
48
    }
49
}
50