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

DocsetNewer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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