AbstractFactory::className()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 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\Adapter\Local;
20
use League\Flysystem\AdapterInterface;
21
use Phauthentic\Infrastructure\Storage\Exception\PackageRequiredException;
22
use Phauthentic\Infrastructure\Storage\InstantiateTrait;
0 ignored issues
show
Bug introduced by
The type Phauthentic\Infrastructu...torage\InstantiateTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
24
/**
25
 * AbstractFactory
26
 */
27
abstract class AbstractFactory implements FactoryInterface
28
{
29
    /**
30
     * @var string
31
     */
32
    protected string $alias = 'local';
33
34
    /**
35
     * @var string|null
36
     */
37
    protected ?string $package = 'league/flysystem';
38
39
    /**
40
     * @var string
41
     */
42
    protected string $className = Local::class;
43
44
    /**
45
     * @return string
46
     */
47 1
    public function className(): string
48
    {
49 1
        return $this->className;
50
    }
51
52
    /**
53
     * @return string
54
     */
55 1
    public function alias(): string
56
    {
57 1
        return $this->alias;
58
    }
59
60
    /**
61
     * @return void
62
     */
63 5
    public function availabilityCheck(): void
64
    {
65 5
        if (!class_exists($this->className)) {
66 1
            throw PackageRequiredException::fromAdapterAndPackageNames(
67 1
                $this->alias,
68 1
                $this->package
0 ignored issues
show
Bug introduced by
It seems like $this->package can also be of type null; however, parameter $package of Phauthentic\Infrastructu...dapterAndPackageNames() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

68
                /** @scrutinizer ignore-type */ $this->package
Loading history...
69
            );
70
        }
71 4
    }
72
73
    /**
74
     * @inheritDoc
75
     */
76
    abstract public function build(array $config): AdapterInterface;
77
}
78