Completed
Push — master ( f4d77b...75a886 )
by Richan
13:04
created

VarnishableService::loadConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace RichanFongdasen\Varnishable;
4
5
use GuzzleHttp\Client;
6
use RichanFongdasen\Varnishable\Concerns\InvalidateVarnishCache;
7
use RichanFongdasen\Varnishable\Concerns\ManipulateHttpResponse;
8
9
class VarnishableService
10
{
11
    use InvalidateVarnishCache;
12
    use ManipulateHttpResponse;
13
    
14
    /**
15
     * Varnishable configurations.
16
     *
17
     * @var array
18
     */
19
    protected $config;
20
21
    /**
22
     * Guzzle client object.
23
     *
24
     * @var \GuzzleHttp\Client
25
     */
26
    protected $guzzle;
27
28
    /**
29
     * Class constructor.
30
     *
31
     * @param \GuzzleHttp\Client $guzzle
32
     */
33
    public function __construct(Client $guzzle)
34
    {
35
        $this->guzzle = $guzzle;
36
        $this->loadConfig();
37
    }
38
39
    /**
40
     * Get configuration value for a specific key.
41
     *
42
     * @param  string $key
43
     * @return mixed
44
     */
45
    public function getConfig($key)
46
    {
47
        return data_get($this->config, $key);
48
    }
49
50
    /**
51
     * Get guzzle client object.
52
     *
53
     * @return \GuzzleHttp\Client
54
     */
55
    public function getGuzzle()
56
    {
57
        return $this->guzzle;
58
    }
59
60
    /**
61
     * Load the configurations.
62
     *
63
     * @return void
64
     */
65
    public function loadConfig()
66
    {
67
        $this->config = app('config')->get('varnishable');
68
    }
69
70
    /**
71
     * Replace the guzzle http client object with
72
     * a new one.
73
     *
74
     * @param \GuzzleHttp\Client $guzzle
75
     */
76
    public function setGuzzle(Client $guzzle)
77
    {
78
        $this->guzzle = $guzzle;
79
    }
80
}
81