Passed
Push — master ( 1476e6...379d7e )
by Guillaume
02:28
created

DocsetArchiver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A archive() 0 15 1
1
<?php
2
3
namespace App\Services;
4
5
use App\Contracts\Docset;
6
7
final class DocsetArchiver
8
{
9
    public $docset;
10
11
12 25
    public function __construct(Docset $docset)
13
    {
14 25
        $this->docset = $docset;
15 25
    }
16
17 1
    public function archive()
18
    {
19 1
        $archiveDirectory = "storage/{$this->docset->code()}";
20
21 1
        system(
22 1
            "tar \
23
            --exclude='.DS_Store' \
24
            -czf \
25 1
            $archiveDirectory/{$this->docset->code()}.tgz \
26 1
            -C $archiveDirectory \
27 1
            {$this->docset->code()}.docset",
28
            $result
29
        );
30
31 1
        return $result === 0;
32
    }
33
}
34