Factory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 15
c 1
b 0
f 0
dl 0
loc 47
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A factory() 0 25 5
A __construct() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace ShopwareEnvironmentVariables\Source\Config;
4
5
use Doctrine\DBAL\Connection;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Connection 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...
6
use Shopware\Components\DependencyInjection\Bridge\Config as ShopwareConfigFactory;
0 ignored issues
show
Bug introduced by
The type Shopware\Components\Depe...Injection\Bridge\Config 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...
7
use Shopware\Components\ShopwareReleaseStruct;
0 ignored issues
show
Bug introduced by
The type Shopware\Components\ShopwareReleaseStruct 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...
8
use ShopwareEnvironmentVariables\Source\Helper\ShopProvider;
9
10
class Factory extends ShopwareConfigFactory
11
{
12
    /**
13
     * @var array
14
     */
15
    private $customConfig;
16
17
    /**
18
     * @var ShopProvider
19
     */
20
    private $shopProvider;
21
22
    /**
23
     * @param ShopProvider $shopProvider
24
     * @param array|null $customConfig
25
     */
26
    public function __construct(ShopProvider $shopProvider, array $customConfig = null)
27
    {
28
        $this->customConfig = $customConfig;
29
        $this->shopProvider = $shopProvider;
30
    }
31
32
    public function factory(
33
        \Zend_Cache_Core $cache,
0 ignored issues
show
Bug introduced by
The type Zend_Cache_Core 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...
34
        Connection $db = null,
35
        $config = [],
36
        ShopwareReleaseStruct $release
37
    ) {
38
        if (!$db) {
39
            return null;
40
        }
41
42
        if (!isset($config['cache'])) {
43
            $config['cache'] = $cache;
44
        }
45
46
        $config['db'] = $db;
47
48
        if ($release) {
0 ignored issues
show
introduced by
$release is of type Shopware\Components\ShopwareReleaseStruct, thus it always evaluated to true.
Loading history...
49
            $config['release'] = $release;
50
        }
51
52
        if ($this->customConfig) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->customConfig of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
53
            $config['custom'] = $this->customConfig;
54
        }
55
56
        return new Config($config, $this->shopProvider->getDefaultShopId());
57
    }
58
}
59