Passed
Pull Request — master (#31)
by Shinji
04:07 queued 02:36
created

PhpSearcherController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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\Inspector\Daemon\Searcher\Controller;
15
16
use Amp\Promise;
0 ignored issues
show
Bug introduced by
The type Amp\Promise 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...
17
use PhpProfiler\Inspector\Daemon\Searcher\Protocol\Message\UpdateTargetProcessMessage;
18
use PhpProfiler\Inspector\Daemon\Searcher\Protocol\Message\TargetRegexMessage;
19
use PhpProfiler\Inspector\Daemon\Searcher\Protocol\PhpSearcherControllerProtocolInterface;
20
use PhpProfiler\Lib\Amphp\ContextInterface;
21
22
final class PhpSearcherController implements PhpSearcherControllerInterface
23
{
24
    /** @var ContextInterface<PhpSearcherControllerProtocolInterface> $context */
25
    private ContextInterface $context;
26
27
    /**
28
     * PhpSearcherContext constructor.
29
     * @param ContextInterface<PhpSearcherControllerProtocolInterface> $context
30
     */
31
    public function __construct(ContextInterface $context)
32
    {
33
        $this->context = $context;
34
    }
35
36
    /**
37
     * @return Promise<null>
38
     */
39
    public function start(): Promise
40
    {
41
        return $this->context->start();
42
    }
43
44
    /**
45
     * @param string $regex
46
     * @return Promise<int>
47
     */
48
    public function sendTargetRegex(string $regex): Promise
49
    {
50
        /** @var Promise<int> */
51
        return $this->context->getProtocol()
52
            ->sendTargetRegex(
53
                new TargetRegexMessage($regex)
54
            )
55
        ;
56
    }
57
58
    /**
59
     * @return Promise<UpdateTargetProcessMessage>
60
     */
61
    public function receivePidList(): Promise
62
    {
63
        /** @var Promise<UpdateTargetProcessMessage> */
64
        return $this->context->getProtocol()->receiveUpdateTargetProcess();
65
    }
66
}
67