Issues (141)

src/Module/SchemeCollectionProvider.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use BEAR\Resource\Annotation\AppName;
8
use BEAR\Resource\AppAdapter;
9
use BEAR\Resource\HttpAdapter;
10
use BEAR\Resource\SchemeCollection;
11
use Override;
12
use Ray\Di\InjectorInterface;
13
use Ray\Di\ProviderInterface;
14
15
/** @implements ProviderInterface<SchemeCollection> */
16
final readonly class SchemeCollectionProvider implements ProviderInterface
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 16 at column 6
Loading history...
17
{
18
    public function __construct(
19
        #[AppName]
20
        private string $appName,
21
        private InjectorInterface $injector,
22
    ) {
23
    }
24
25
    /**
26
     * Return instance
27
     */
28
    #[Override]
29
    public function get(): SchemeCollection
30
    {
31
        $schemeCollection = new SchemeCollection();
32
        $pageAdapter = new AppAdapter($this->injector, $this->appName);
33
        $appAdapter = new AppAdapter($this->injector, $this->appName);
34
        $schemeCollection->scheme('page')->host('self')->toAdapter($pageAdapter);
35
        $schemeCollection->scheme('app')->host('self')->toAdapter($appAdapter);
36
        $schemeCollection->scheme('http')->host('self')->toAdapter(new HttpAdapter($this->injector));
37
38
        return $schemeCollection;
39
    }
40
}
41