CookieConsent::forNecessary()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace DigiFactory\CookieConsent;
4
5
use DigiFactory\CookieConsent\Contracts\ConsentProvider;
6
use Illuminate\Config\Repository;
7
8
class CookieConsent
9
{
10
    const CONSENT_NECESSARY = 'necessary';
11
    const CONSENT_PREFERENCES = 'preferences';
12
    const CONSENT_STATISTICS = 'statistics';
13
    const CONSENT_MARKETING = 'marketing';
14
15
    protected $enabled;
16
    protected $provider;
17
18
    public function __construct(ConsentProvider $provider, Repository $config)
19
    {
20
        $this->enabled = $config['cookie-consent']['enabled'];
21
        $this->provider = $provider;
22
    }
23
24
    public function forNecessary()
25
    {
26
        return ! $this->enabled || $this->provider->forNecessary();
27
    }
28
29
    public function forPreferences()
30
    {
31
        return ! $this->enabled || $this->provider->forPreferences();
32
    }
33
34
    public function forStatistics()
35
    {
36
        return ! $this->enabled || $this->provider->forStatistics();
37
    }
38
39
    public function forMarketing()
40
    {
41
        return ! $this->enabled || $this->provider->forMarketing();
42
    }
43
}
44