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

GzipArchiver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A unarchive() 0 16 3
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