ZipArchiveFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 10 1
1
<?php
2
3
/**
4
 * Copyright (c) Florian Krämer (https://florian-kraemer.net)
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE.txt
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net)
10
 * @author    Florian Krämer
11
 * @link      https://github.com/Phauthentic
12
 * @license   https://opensource.org/licenses/MIT MIT License
13
 */
14
15
declare(strict_types=1);
16
17
namespace Phauthentic\Infrastructure\Storage\Factories;
18
19
use League\Flysystem\AdapterInterface;
20
use League\Flysystem\WebDAV\WebDAVAdapter;
21
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
22
23
/**
24
 * ZipArchiveFactory
25
 */
26
class ZipArchiveFactory extends AbstractFactory
27
{
28
    protected string $alias = 'zip';
29
    protected ?string $package = 'league/flysystem-ziparchive';
30
    protected string $className = ZipArchiveAdapter::class;
31
32
    /**
33
     * @inheritDoc
34
     */
35 1
    public function build(array $config): AdapterInterface
36
    {
37
        $defaults = [
38 1
            'location' => null,
39
            'archive' => null,
40
            'prefix' => null,
41
        ];
42 1
        $config += $defaults;
43
44 1
        return new ZipArchiveAdapter($config['location'], $config['archive'], $config['prefix']);
45
    }
46
}
47