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

Installer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getComponentName() 0 4 1
A install() 0 21 3
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