Storage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 7 2
A setAdapter() 0 3 1
1
<?php
2
/*
3
 * This file is part of the Scrawler package.
4
 *
5
 * (c) Pranjal Pandey <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Scrawler;
12
13
use League\Flysystem\FilesystemAdapter;
14
15
/**
16
 * Scrawler Filesystem Class.
17
 *
18
 * @mixin \Scrawler\StorageEngine
19
 */
20
class Storage
21
{
22
    private ?StorageEngine $engine = null;
23
24
    public const PUBLIC = 'public';
25
    public const PRIVATE = 'private';
26
27
    public function setAdapter(FilesystemAdapter $adapter): void
28
    {
29
        $this->engine = new StorageEngine($adapter);
30
    }
31
32
    /**
33
     * @param array<mixed> $args
34
     *
35
     * @throws \Exception
36
     */
37
    public function __call(string $method, array $args): mixed
38
    {
39
        if (is_null($this->engine)) {
40
            throw new \Exception('Please set adapter using storage()->setAdapter($adapter) first');
41
        }
42
43
        return $this->engine->$method(...$args);
44
    }
45
}
46