CookieConsent   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A forNecessary() 0 4 2
A forPreferences() 0 4 2
A forStatistics() 0 4 2
A forMarketing() 0 4 2
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