Passed
Push — master ( 15bc58...710bbc )
by Maciej
03:55
created

PurgingConfigProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 44
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isPurgeCustomHostEnabled() 0 4 1
A getCustomPurgeHost() 0 4 1
A getAdditionalHostForHeader() 0 4 1
1
<?php
2
/**
3
 * File: PurgingConfigProvider.php
4
 *
5
 * @author Maciej Sławik <[email protected]>
6
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
7
 */
8
9
namespace LizardMedia\VarnishWarmer\Model\Config;
10
11
use LizardMedia\VarnishWarmer\Api\Config\PurgingConfigProviderInterface;
12
use Magento\Framework\App\Config\ScopeConfigInterface;
13
14
/**
15
 * Class PurgingConfigProvider
16
 * @package LizardMedia\VarnishWarmer\Api\Config
17
 */
18
class PurgingConfigProvider implements PurgingConfigProviderInterface
19
{
20
    const XML_PATH_USE_CUSTOM_HOST = 'lm_varnish/purge/different_purge_host';
21
    const XML_PATH_CUSTOM_HOST = 'lm_varnish/purge/custom_host';
22
    const XML_PATH_CUSTOM_HEADER_HOST = 'lm_varnish/purge/header_host';
23
24
    /**
25
     * @var ScopeConfigInterface
26
     */
27
    protected $scopeConfig;
28
29
    /**
30
     * GeneralConfigProvider constructor.
31
     * @param ScopeConfigInterface $scopeConfig
32
     */
33
    public function __construct(ScopeConfigInterface $scopeConfig)
34
    {
35
        $this->scopeConfig = $scopeConfig;
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function isPurgeCustomHostEnabled(): bool
42
    {
43
        return (bool)$this->scopeConfig->getValue(self::XML_PATH_USE_CUSTOM_HOST);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getCustomPurgeHost(): string
50
    {
51
        return (string)$this->scopeConfig->getValue(self::XML_PATH_CUSTOM_HOST);
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getAdditionalHostForHeader(): string
58
    {
59
        return (string)$this->scopeConfig->getValue(self::XML_PATH_CUSTOM_HEADER_HOST);
60
    }
61
}
62