Completed
Push — master ( 53f5bb...267586 )
by recca
02:53
created

Kernel::queue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Recca0120\Terminal;
4
5
use Illuminate\Support\Arr;
6
use Recca0120\Terminal\Application as Artisan;
7
use Illuminate\Contracts\Console\Kernel as KernelContract;
8
9
class Kernel implements KernelContract
10
{
11
    /**
12
     * The Artisan application instance.
13
     *
14
     * @var \Illuminate\Console\Application
15
     */
16
    protected $artisan;
17
18
    /**
19
     * $config.
20
     *
21
     * @var array
22
     */
23
    protected $config;
24
25
    /**
26
     * The Artisan commands provided by the application.
27
     *
28
     * @var array
29
     */
30
    protected $commands = [];
31
32
    /**
33
     * Create a new console kernel instance.
34
     *
35
     * @param \Recca0120\Terminal\Application $artisan
36
     */
37 6
    public function __construct(Artisan $artisan, $config = [])
38
    {
39 6
        $this->artisan = $artisan;
40 6
        $this->config = Arr::except(array_merge([
41 6
            'username' => 'LARAVEL',
42 6
            'hostname' => php_uname('n'),
43 6
            'os' => PHP_OS,
44 6
        ], $config), [
45 6
            'enabled',
46 6
            'whitelists',
47 6
            'route',
48 6
            'commands',
49 6
        ]);
50 6
    }
51
52
    /**
53
     * getConfig.
54
     *
55
     * @return array
56
     */
57
    public function getConfig()
58
    {
59
        return $this->config;
60
    }
61
62
    /**
63
     * Handle an incoming console command.
64
     *
65
     * @param \Symfony\Component\Console\Input\InputInterface $input
66
     * @param \Symfony\Component\Console\Output\OutputInterface $output
67
     * @return int
68
     */
69 1
    public function handle($input, $output = null)
70
    {
71 1
        return $this->artisan->run($input, $output);
72
    }
73
74
    /**
75
     * Run an Artisan console command by name.
76
     *
77
     * @param string $command
78
     * @param array $parameters
79
     * @return int
80
     */
81 1
    public function call($command, array $parameters = [])
82
    {
83 1
        return $this->artisan->call($command, $parameters);
84
    }
85
86
    /**
87
     * Queue an Artisan console command by name.
88
     *
89
     * @param string $command
90
     * @param array $parameters
91
     * @return void
92
     */
93 1
    public function queue($command, array $parameters = [])
94
    {
95 1
        $app = $this->artisan->getLaravel();
96 1
        $app['Illuminate\Contracts\Queue\Queue']->push(
97 1
            'Illuminate\Foundation\Console\QueuedJob', func_get_args()
98 1
        );
99 1
    }
100
101
    /**
102
     * Get all of the commands registered with the console.
103
     *
104
     * @return array
105
     */
106 1
    public function all()
107
    {
108 1
        return $this->artisan->all();
109
    }
110
111
    /**
112
     * Get the output for the last run command.
113
     *
114
     * @return string
115
     */
116 1
    public function output()
117
    {
118 1
        return $this->artisan->output();
119
    }
120
}
121