ShopStorage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentShopIdentifier() 0 8 2
A hasCurrentShop() 0 4 1
A getCurrentShop() 0 4 1
A setCurrentShop() 0 4 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\AppBundle\Service\Shop\Storage;
14
15
use WellCommerce\Bundle\AppBundle\Entity\Shop;
16
17
/**
18
 * Class ShopStorage
19
 *
20
 * @author  Adam Piotrowski <[email protected]>
21
 */
22
final class ShopStorage implements ShopStorageInterface
23
{
24
    /**
25
     * @var Shop
26
     */
27
    private $currentShop;
28
    
29
    public function getCurrentShopIdentifier(): int
30
    {
31
        if ($this->hasCurrentShop()) {
32
            return $this->getCurrentShop()->getId();
33
        }
34
        
35
        return 0;
36
    }
37
    
38
    public function hasCurrentShop(): bool
39
    {
40
        return $this->currentShop instanceof Shop;
41
    }
42
    
43
    public function getCurrentShop(): Shop
44
    {
45
        return $this->currentShop;
46
    }
47
    
48
    public function setCurrentShop(Shop $shop)
49
    {
50
        $this->currentShop = $shop;
51
    }
52
}
53