Kernel   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 91.43%

Importance

Changes 0
Metric Value
dl 0
loc 145
ccs 32
cts 35
cp 0.9143
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 2

9 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 6 1
A __construct() 0 7 1
A getConfig() 0 4 1
A bootstrap() 0 3 1
A call() 0 6 1
A queue() 0 13 2
A all() 0 6 1
A output() 0 6 1
A terminate() 0 5 1
1
<?php
2
3
namespace Recca0120\Terminal;
4
5
use Exception;
6
use Illuminate\Contracts\Console\Kernel as KernelContract;
7
use Illuminate\Contracts\Queue\Queue;
8
use Illuminate\Foundation\Console\QueuedCommand;
9
use Illuminate\Support\Arr;
10
use Recca0120\Terminal\Application as Artisan;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class Kernel implements KernelContract
15
{
16
    /**
17
     * The Artisan application instance.
18
     *
19
     * @var \Illuminate\Console\Application
20
     */
21
    protected $artisan;
22
23
    /**
24
     * $config.
25
     *
26
     * @var array
27
     */
28
    protected $config;
29
30
    /**
31
     * The Artisan commands provided by the application.
32
     *
33
     * @var array
34
     */
35
    protected $commands = [];
36
37 7
    /**
38
     * Create a new console kernel instance.
39 7
     *
40 7
     * @param Application $artisan
41 7
     * @param array $config
42 7
     */
43 7
    public function __construct(Artisan $artisan, $config = [])
44
    {
45 7
        $this->artisan = $artisan;
46
        $this->config = Arr::except(array_merge([
47
            'username' => 'LARAVEL', 'hostname' => php_uname('n'), 'os' => PHP_OS,
48
        ], $config), ['enabled', 'whitelists', 'route', 'commands']);
49
    }
50 7
51
    /**
52
     * getConfig.
53
     *
54
     * @return array
55
     */
56
    public function getConfig()
57
    {
58
        return $this->config;
59
    }
60
61
    /**
62
     * Bootstrap the application for artisan commands.
63
     *
64
     * @return void
65
     */
66
    public function bootstrap()
67 6
    {
68
    }
69 6
70
    /**
71
     * Handle an incoming console command.
72
     *
73
     * @param InputInterface $input
74
     * @param OutputInterface $output
75
     * @return int
76
     * @throws Exception
77
     */
78 1
    public function handle($input, $output = null)
79
    {
80 1
        $this->bootstrap();
81
82 1
        return $this->artisan->run($input, $output);
83
    }
84
85
    /**
86
     * Run an Artisan console command by name.
87
     *
88
     * @param string $command
89
     * @param array $parameters
90
     * @param OutputInterface $outputBuffer
91
     * @return int
92
     * @throws Exception
93 1
     */
94
    public function call($command, array $parameters = [], $outputBuffer = null)
95 1
    {
96
        $this->bootstrap();
97 1
98
        return $this->artisan->call($command, $parameters, $outputBuffer);
99
    }
100
101
    /**
102
     * Queue an Artisan console command by name.
103
     *
104
     * @param string $command
105
     * @param array $parameters
106
     * @return void
107 1
     */
108
    public function queue($command, array $parameters = [])
109 1
    {
110 1
        $this->bootstrap();
111 1
112 1
        if (class_exists(QueuedCommand::class)) {
113
            return QueuedCommand::dispatch(func_get_args());
114 1
        }
115
116
        $app = $this->artisan->getLaravel();
117
        $app[Queue::class]->push(
118
            'Illuminate\Foundation\Console\QueuedJob', func_get_args()
119
        );
120
    }
121 1
122
    /**
123 1
     * Get all of the commands registered with the console.
124
     *
125 1
     * @return array
126
     */
127
    public function all()
128
    {
129
        $this->bootstrap();
130
131
        return $this->artisan->all();
132
    }
133 1
134
    /**
135 1
     * Get the output for the last run command.
136
     *
137 1
     * @return string
138
     */
139
    public function output()
140
    {
141
        $this->bootstrap();
142
143
        return $this->artisan->output();
144
    }
145
146
    /**
147 1
     * Terminate the application.
148
     *
149 1
     * @param InputInterface $input
150 1
     * @param int $status
151 1
     * @return void
152
     */
153
    public function terminate($input, $status)
154
    {
155
        $this->bootstrap();
156
        $this->artisan->terminate();
0 ignored issues
show
Bug introduced by
The method terminate() does not seem to exist on object<Illuminate\Console\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
157
    }
158
}
159