FilesystemManager::validatePlugin()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * BsbFlystem
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @see       https://bushbaby.nl/
10
 *
11
 * @copyright Copyright (c) 2014-2021 bushbaby multimedia. (https://bushbaby.nl)
12
 * @author    Bas Kamer <[email protected]>
13
 * @license   MIT
14
 *
15
 * @package   bushbaby/flysystem
16
 */
17
18
declare(strict_types=1);
19
20
namespace BsbFlysystem\Service;
21
22
use BsbFlysystem\Exception\RuntimeException;
23
use Laminas\ServiceManager\AbstractPluginManager;
24
use Laminas\ServiceManager\Exception;
25
use League\Flysystem\FilesystemInterface;
26
27
class FilesystemManager extends AbstractPluginManager
28 5
{
29
    /**
30 5
     * @var string
31 1
     */
32 1
    protected $instanceOf = FilesystemInterface::class;
33 1
34 1
    /**
35
     * @var bool
36
     */
37 5
    protected $shareByDefault = true;
38
39 1
    /**
40
     * @var bool
41
     */
42 1
    protected $sharedByDefault = true;
43 1
44 1
    public function validate($instance): void
45
    {
46 1 View Code Duplication
        if (! $instance instanceof $this->instanceOf) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
            throw new Exception\InvalidServiceException(\sprintf('Invalid filesystem "%s" created; not an instance of %s', \get_class($instance), $this->instanceOf));
48
        }
49
    }
50
51
    public function validatePlugin($instance): void
52
    {
53
        try {
54
            $this->validate($instance);
55
        } catch (Exception\InvalidServiceException $e) {
56
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
57
        }
58
    }
59
}
60