Completed
Push — 2.0 ( 359ae1...221cc7 )
by Rafał
51:27 queued 18:07
created

GzipArchiver::unarchive()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Publisher Archiver Component.
7
 *
8
 * Copyright 2019 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2019 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Component\Archiver\Archiver;
18
19
class GzipArchiver implements ArchiverInterface
20
{
21
    public function unarchive(string $source, string $target): bool
22
    {
23
        $file = gzopen($source, 'rb');
24
        $output = fopen($target, 'wb');
25
26
        while (!gzeof($file)) {
27
            if (false === fwrite($output, gzread($file, 4096))) {
28
                return false;
29
            }
30
        }
31
32
        fclose($output);
33
        gzclose($file);
34
35
        return true;
36
    }
37
}
38