Completed
Branch dev (d5d70c)
by Raffael
11:00
created

Job::start()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Convert;
13
14
use Balloon\Server;
15
use TaskScheduler\AbstractJob;
16
use TaskScheduler\Async;
17
18
class Job extends AbstractJob
19
{
20
    /**
21
     * Converter.
22
     *
23
     * @var Converter
24
     */
25
    protected $converter;
26
27
    /**
28
     * Server.
29
     *
30
     * @var Server
31
     */
32
    protected $server;
33
34
    /**
35
     * Async.
36
     *
37
     * @var Async
38
     */
39
    protected $async;
40
41
    /**
42
     * Constructor.
43
     *
44
     * @param Async $async
45
     */
46
    public function __construct(Server $server, Async $async, Converter $converter)
47
    {
48
        $this->server = $server;
49
        $this->async = $async;
50
        $this->converter = $converter;
51
    }
52
53
    /**
54
     * Start job.
55
     *
56
     * @param Server          $server
0 ignored issues
show
Bug introduced by
There is no parameter named $server. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
57
     * @param LoggerInterface $logger
0 ignored issues
show
Bug introduced by
There is no parameter named $logger. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
58
     *
59
     * @return bool
60
     */
61
    public function start(): bool
62
    {
63
        $master = $this->server->getFilesystem()->findNodeById($this->data['master']);
64
65
        if (isset($this->data['id'])) {
66
            $this->converter->convert($this->data['id'], $master);
0 ignored issues
show
Compatibility introduced by
$master of type object<Balloon\Filesystem\Node\NodeInterface> is not a sub-type of object<Balloon\Filesystem\Node\File>. It seems like you assume a concrete implementation of the interface Balloon\Filesystem\Node\NodeInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
67
        } else {
68
            foreach ($this->converter->getSlaves($master) as $slave) {
0 ignored issues
show
Compatibility introduced by
$master of type object<Balloon\Filesystem\Node\NodeInterface> is not a sub-type of object<Balloon\Filesystem\Node\File>. It seems like you assume a concrete implementation of the interface Balloon\Filesystem\Node\NodeInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
69
                $this->async->addJob(self::class, [
70
                    'master' => $this->data['master'],
71
                    'id' => $slave['_id'],
72
                ]);
73
            }
74
        }
75
76
        return true;
77
    }
78
}
79