Passed
Push — master ( f832ac...3bedb1 )
by PHPinnacle
05:03 queued 02:22
created

ParallelProcessor::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of PHPinnacle/Ensign.
4
 *
5
 * (c) PHPinnacle Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types = 1);
12
13
namespace PHPinnacle\Ensign\Processor;
14
15
use Amp\Parallel\Worker\DefaultPool;
0 ignored issues
show
Bug introduced by
The type Amp\Parallel\Worker\DefaultPool 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...
16
use Amp\Parallel\Worker\Pool;
0 ignored issues
show
Bug introduced by
The type Amp\Parallel\Worker\Pool 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 Amp\ParallelFunctions;
0 ignored issues
show
Bug introduced by
The type Amp\ParallelFunctions 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
use Amp\Promise;
19
use PHPinnacle\Ensign\Contract;
20
21
final class ParallelProcessor implements Contract\Processor
22
{
23
    /**
24
     * @var Pool
25
     */
26
    private $pool;
27
28
    /**
29
     * @param Pool $pool
30
     */
31
    public function __construct(Pool $pool = null)
32
    {
33
        $this->pool = $pool ?: new DefaultPool();
34
    }
35
36
    /**
37
     * @return Promise
38
     */
39
    public function shutdown(): Promise
40
    {
41
        return $this->pool->shutdown();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function execute(callable $handler, array $arguments)
48
    {
49
        $parallel = ParallelFunctions\parallel($handler, $this->pool);
0 ignored issues
show
Bug introduced by
The function parallel 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

49
        $parallel = /** @scrutinizer ignore-call */ ParallelFunctions\parallel($handler, $this->pool);
Loading history...
50
51
        return $parallel(...$arguments);
52
    }
53
}
54