Completed
Pull Request — master (#200)
by Raffael
16:31
created

Factory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\Filesystem\Storage;
13
14
use Balloon\Filesystem\Storage\Adapter\AdapterInterface;
15
use Balloon\Filesystem\Storage\Adapter\Smb;
16
use Balloon\Filesystem\Storage\Adapter\Smb\Factory as SmbFactory;
17
use Psr\Log\LoggerInterface;
18
19
class Factory
20
{
21
    /**
22
     * Adapters.
23
     */
24
    const ADAPTERS = [
25
        'smb' => Smb::class,
26
    ];
27
28
    /**
29
     * Logger.
30
     *
31
     * @var LoggerInterface
32
     */
33
    protected $logger;
34
35
    /**
36
     * SMB factory.
37
     *
38
     * @var SmbFactory
39
     */
40
    protected $smb_factory;
41
42
    /**
43
     * Storage handler.
44
     */
45
    public function __construct(LoggerInterface $logger, SmbFactory $smb_factory)
46
    {
47
        $this->logger = $logger;
48
        $this->smb_factory = $smb_factory;
49
    }
50
51
    /**
52
     * Create adapter.
53
     */
54
    public function build(array $options): AdapterInterface
55
    {
56
        $options = Validator::validate($options);
57
        $adapter = self::ADAPTERS[$options['adapter']];
0 ignored issues
show
Unused Code introduced by
$adapter is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
59
        return $this->smb_factory->build($options);
60
    }
61
}
62