Passed
Push — master ( de3cce...9ef401 )
by Guillaume
07:53
created

DocsetArchiver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Godbout\DashDocsetBuilder\Services;
4
5
use Godbout\DashDocsetBuilder\Contracts\Docset;
6
7
final class DocsetArchiver
8
{
9
    public $docset;
10
11
12
    public function __construct(Docset $docset)
13
    {
14
        $this->docset = $docset;
15
    }
16
17
    public function archive()
18
    {
19
        $archiveDirectory = "storage/{$this->docset->code()}";
20
21
        system(
22
            "tar \
23
            --exclude='.DS_Store' \
24
            -czf \
25
            $archiveDirectory/{$this->docset->code()}.tgz \
26
            -C $archiveDirectory \
27
            {$this->docset->code()}.docset",
28
            $result
29
        );
30
31
        return $result === 0;
32
    }
33
}
34