ShopProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultShop() 0 3 1
A __construct() 0 4 1
A getDefaultShopId() 0 3 1
A getShop() 0 7 2
A getShopId() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace ShopwareEnvironmentVariables\Source\Helper;
4
5
use Shopware\Components\Model\ModelManager;
0 ignored issues
show
Bug introduced by
The type Shopware\Components\Model\ModelManager 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\Models\Shop\Shop;
0 ignored issues
show
Bug introduced by
The type Shopware\Models\Shop\Shop 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
8
class ShopProvider
9
{
10
    /**
11
     * @var null|Shop
12
     */
13
    private $shop;
14
15
    /**
16
     * @var ModelManager
17
     */
18
    private $models;
19
20
    /**
21
     * @param ModelManager $models
22
     * @param Shop|null $shop
23
     */
24
    public function __construct(ModelManager $models, Shop $shop = null)
25
    {
26
        $this->models = $models;
27
        $this->shop = $shop;
28
    }
29
30
    /**
31
     * @return Shop
32
     */
33
    public function getShop(): Shop
34
    {
35
        if (!$this->shop) {
36
            $this->shop = $this->getDefaultShop();
37
        }
38
39
        return $this->shop;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getShopId(): int
46
    {
47
        return $this->getShop()->getId();
48
    }
49
50
    /**
51
     * @return \Shopware\Models\Shop\DetachedShop
0 ignored issues
show
Bug introduced by
The type Shopware\Models\Shop\DetachedShop 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...
52
     */
53
    public function getDefaultShop()
54
    {
55
        return $this->models->getRepository(Shop::class)->getActiveDefault();
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function getDefaultShopId()
62
    {
63
        return $this->getDefaultShop()->getId();
64
    }
65
}
66