Completed
Pull Request — stable (#354)
by Matt
04:09
created

Installer::install()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 18
ccs 0
cts 11
cp 0
rs 9.9
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Laravel Zero.
7
 *
8
 * (c) Nuno Maduro <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace LaravelZero\Framework\Components\Queue;
15
16
use Illuminate\Support\Facades\File;
17
use LaravelZero\Framework\Components\AbstractInstaller;
18
19
/**
20
 * @internal
21
 */
22
final class Installer extends AbstractInstaller
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected $name = 'install:queue';
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    protected $description = 'Queues: Unified API across a variety of queue services';
33
34
    /**
35
     * The config file path.
36
     */
37
    private const CONFIG_FILE = __DIR__.DIRECTORY_SEPARATOR.'stubs'.DIRECTORY_SEPARATOR.'queue.php';
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function install(): void
43
    {
44
        $this->call('app:install', ['component' => 'database']);
45
46
        $this->require('illuminate/bus "5.8.*"');
47
        $this->require('illuminate/queue "5.8.*"');
48
49
        $this->task(
50
            'Creating default queue configuration',
51
            function () {
52
                if (! File::exists(config_path('queue.php'))) {
53
                    return File::copy(
54
                        static::CONFIG_FILE,
55
                        $this->app->configPath('queue.php')
56
                    );
57
                }
58
59
                return false;
60
            }
61
        );
62
    }
63
}
64