Passed
Push — stable ( bf53fe...29e605 )
by Nuno
06:22
created

Installer::getComponentName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LaravelZero\Framework\Commands\Component\Vlucas\Phpdotenv;
4
5
use Illuminate\Support\Facades\File;
6
use LaravelZero\Framework\Commands\Component\Installer as BaseInstaller;
7
use LaravelZero\Framework\Contracts\Commands\Component\Installer as InstallerContract;
8
9
/**
10
 * This is the Laravel Zero Framework vlucas/phpdotent install class.
11
 *
12
 * @author Nuno Maduro <[email protected]>
13
 */
14
class Installer extends BaseInstaller implements InstallerContract
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected $name = 'install:dotenv';
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    protected $description = 'Installs vlucas/phpdotenv';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function getComponentName(): string
30
    {
31 2
        return 'dotenv';
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function install(): bool
38
    {
39 2
        $this->require('vlucas/phpdotenv');
40
41 2
        $this->task(
42 2
            'Creating .env and .env.example',
43 2
            function () {
44 2
                if (! File::exists(base_path('.env'))) {
45 2
                    File::put(base_path('.env'), 'CONSUMER_KEY=');
46
                }
47
48 2
                if (! File::exists(base_path('.env.example'))) {
49 2
                    File::put(base_path('.env.example'), 'CONSUMER_KEY=');
50
                }
51
52 2
                return true;
53 2
            }
54
        );
55
56 2
        return true;
57
    }
58
}
59