Test Setup Failed
Push — develop ( 04b246...d52f7e )
by Nikita
10:40
created

Archiver::extractTarGzip()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 12
rs 10
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Gameap\Adapters;
4
5
use splitbrain\PHPArchive\Tar;
6
7
class Archiver
8
{
9
    /**
10
     * @throws \splitbrain\PHPArchive\ArchiveCorruptedException
11
     * @throws \splitbrain\PHPArchive\ArchiveIOException
12
     * @throws \splitbrain\PHPArchive\ArchiveIllegalCompressionException
13
     */
14
    public function extractTarGzip(string $path, string $destination, int $strip = 0): array
15
    {
16
        $tar = new Tar();
17
        $tar->open($path);
18
        $contents = $tar->extract($destination, $strip);
19
20
        $fileList = [];
21
        foreach ($contents as $file) {
22
            $fileList[] = $file->getPath();
23
        }
24
25
        return $fileList;
26
    }
27
}
28