Passed
Pull Request — master (#407)
by Kirill
11:08 queued 03:58
created

StorageEngineAbstractTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildSimpleStorageEngine() 0 11 3
A mountStorageEngineFileSystem() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Tests\Storage\Unit;
6
7
use League\Flysystem\FilesystemOperator;
8
use Spiral\Storage\Exception\ConfigException;
9
use Spiral\Storage\Exception\StorageException;
10
use Spiral\Storage\Storage;
11
use Spiral\Tests\Storage\Traits\LocalFsBuilderTrait;
12
13
abstract class StorageEngineAbstractTest extends UnitTestCase
14
{
15
    use LocalFsBuilderTrait;
16
17
    /**
18
     * @param string|null $fs
19
     * @param FilesystemOperator|null $fileSystem
20
     *
21
     * @return Storage
22
     *
23
     * @throws StorageException
24
     * @throws ConfigException
25
     * @throws \ReflectionException
26
     */
27
    protected function buildSimpleStorageEngine(
28
        ?string $fs = null,
29
        ?FilesystemOperator $fileSystem = null
30
    ): Storage {
31
        $engine = new Storage($this->buildStorageConfig(), $this->getUriParser());
32
33
        if (!empty($fs) && $fileSystem !== null) {
34
            $this->mountStorageEngineFileSystem($engine, $fs, $fileSystem);
35
        }
36
37
        return $engine;
38
    }
39
40
    /**
41
     * @param Storage $engine
42
     * @param string $fs
43
     * @param FilesystemOperator $fileSystem
44
     *
45
     * @throws \ReflectionException
46
     */
47
    protected function mountStorageEngineFileSystem(
48
        Storage $engine,
49
        string $fs,
50
        FilesystemOperator $fileSystem
51
    ): void {
52
        $this->callNotPublicMethod($engine, 'mountFilesystem', [$fs, $fileSystem]);
0 ignored issues
show
Deprecated Code introduced by
The function Spiral\Tests\Storage\Uni...::callNotPublicMethod() has been deprecated: Tests should not use this method to call internal implementation ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

52
        /** @scrutinizer ignore-deprecated */ $this->callNotPublicMethod($engine, 'mountFilesystem', [$fs, $fileSystem]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
53
    }
54
}
55