Test Setup Failed
Push — master ( 3ed728...b3b03e )
by Php Easy Api
03:22
created

Worker::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 0
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Console\Source\Worker;
4
5
use Resta\Console\ConsoleOutputter;
6
use Resta\Console\ConsoleListAccessor;
7
8
class Worker extends ConsoleOutputter {
9
10
    use ConsoleListAccessor;
11
12
    /**
13
     * @var $type
0 ignored issues
show
Documentation Bug introduced by
The doc comment $type at position 0 could not be parsed: Unknown type name '$type' at position 0 in $type.
Loading history...
14
     */
15
    public $type = 'worker';
16
17
    /**
18
     * @var $define
0 ignored issues
show
Documentation Bug introduced by
The doc comment $define at position 0 could not be parsed: Unknown type name '$define' at position 0 in $define.
Loading history...
19
     */
20
    public $define = 'begins worker for application';
21
22
    /**
23
     * @var $commandRule
0 ignored issues
show
Documentation Bug introduced by
The doc comment $commandRule at position 0 could not be parsed: Unknown type name '$commandRule' at position 0 in $commandRule.
Loading history...
24
     */
25
    public $commandRule = ['get'=>['worker']];
26
27
    /**
28
     * @return mixed
29
     */
30
    public function get()
31
    {
32
        $worker = strtolower($this->argument['worker']);
33
34
        $registeredWorkers = app()->get('worker');
35
36
        if(isset($registeredWorkers[$worker])){
37
            while(true){
38
                echo $this->classical($registeredWorkers[$worker](1));
39
                sleep(10);
40
            }
41
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
42
        }
43
44
        exception()->runtime('Any worker is not available');
45
    }
46
}