ContextCreator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\Amphp;
15
16
use function Amp\Parallel\Context\create;
0 ignored issues
show
introduced by
The function Amp\Parallel\Context\create was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
17
18
final class ContextCreator implements ContextCreatorInterface
19
{
20
    public const ENTRY_SCRIPT = __DIR__ . '/worker-entry.php';
21
22
    public function __construct(
23
        private string $di_config_file
24
    ) {
25
    }
26
27
    /**
28
     * @template TWorkerProtocol of MessageProtocolInterface
29
     * @template TControllerProtocol of MessageProtocolInterface
30
     * @param class-string<WorkerEntryPointInterface> $entry_point_class
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<WorkerEntryPointInterface> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<WorkerEntryPointInterface>.
Loading history...
31
     * @param class-string<TWorkerProtocol> $worker_protocol_class
32
     * @param class-string<TControllerProtocol> $controller_protocol_class
33
     * @return ContextInterface<TControllerProtocol>
34
     */
35
    public function create(
36
        string $entry_point_class,
37
        string $worker_protocol_class,
38
        string $controller_protocol_class
39
    ): ContextInterface {
40
        $amphp_cotext = create([
0 ignored issues
show
Bug introduced by
The function create was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $amphp_cotext = /** @scrutinizer ignore-call */ create([
Loading history...
41
            self::ENTRY_SCRIPT,
42
            $entry_point_class,
43
            $worker_protocol_class,
44
            $this->di_config_file,
45
        ]);
46
47
        /** @var ContextInterface<TControllerProtocol> */
48
        return new Context(
49
            $amphp_cotext,
50
            $controller_protocol_class::createFromChannel($amphp_cotext)
51
        );
52
    }
53
}
54