Passed
Push — master ( 636760...d1dc62 )
by Guillaume
08:55
created

DocsetNewer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 30
ccs 3
cts 15
cp 0.2
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A new() 0 21 2
1
<?php
2
3
namespace Godbout\DashDocsetBuilder\Services;
4
5
use Godbout\DashDocsetBuilder\Contracts\Docset;
6
use Illuminate\Support\Facades\Artisan;
7
use Illuminate\Support\Facades\Config;
8
use Illuminate\Support\Facades\DB;
9
use Illuminate\Support\Facades\File;
10
use Illuminate\Support\Facades\Storage;
11
use Illuminate\Support\Str;
12
13
final class DocsetNewer
14
{
15
    protected $docsetName;
16
17 18
    public function __construct(?string $docsetName)
18
    {
19 18
        $this->docsetName = $docsetName;
20 18
    }
21
22
    public function new()
23
    {
24
        $userDocsetsDirectory = app_path() . '/../../../../app/Docsets';
25
26
        File::makeDirectory($userDocsetsDirectory, 0755, true, true);
27
28
        if (! $this->docsetName) {
29
            File::copy(
30
                app_path() . '/Services/stubs/RickAstley.stub',
31
                $userDocsetsDirectory . '/RickAstley.php'
32
            );
33
34
            return true;
35
        }
36
37
        File::put(
38
            $userDocsetsDirectory . '/' . Str::studly($this->docsetName) . '.php',
39
            '<?php blah blah blah'
40
        );
41
42
        return true;
43
    }
44
}
45