Passed
Push — master ( 47e248...a43368 )
by Raffael
09:50
created

Jobs::listen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
crap 2
eloc 5
nc 1
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\Cli\Console;
13
14
use Balloon\Hook;
15
use GetOpt\GetOpt;
16
use Psr\Log\LoggerInterface;
17
use TaskScheduler\Async;
18
19
class Jobs
20
{
21
    /**
22
     * Logger.
23
     *
24
     * @var LoggerInterface
25
     */
26
    protected $logger;
27
28
    /**
29
     * Getopt.
30
     *
31
     * @var GetOpt
32
     */
33
    protected $getopt;
34
35
    /**
36
     * Async.
37
     *
38
     * @var Async
39
     */
40
    protected $async;
41
42
    /**
43
     * Hook.
44
     *
45
     * @var Hook
46
     */
47
    protected $hook;
48
49
    /**
50
     * Constructor.
51
     *
52
     * @param App             $app
0 ignored issues
show
Bug introduced by
There is no parameter named $app. 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...
53
     * @param Async           $async
54
     * @param LoggerInterface $logger
55
     * @param GetOpt          $getopt
56
     */
57
    public function __construct(Hook $hook, Async $async, LoggerInterface $logger, GetOpt $getopt)
58
    {
59
        $this->async = $async;
60
        $this->hook = $hook;
61
        $this->logger = $logger;
62
        $this->getopt = $getopt;
63
        $this->async = $async;
64
    }
65
66
    /**
67
     * Start.
68
     *
69
     * @return bool
70
     */
71
    public function listen(): bool
72
    {
73
        $this->logger->info('daemon execution requested, fire up daemon', [
74
            'category' => get_class($this),
75
        ]);
76
77
        $this->hook->run('preExecuteAsyncJobs');
78
        $this->async->startDaemon();
79
    }
80
81
    /*
82
     * Start.
83
     *
84
     * @return bool
85
     */
86
    public function once(): bool
87
    {
88
        $this->hook->run('preExecuteAsyncJobs');
89
        $this->async->startOnce();
90
        $this->hook->run('postExecuteAsyncJobs');
91
92
        return true;
93
    }
94
}
95