AbstractResourcesAwareQuery   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 38
c 0
b 0
f 0
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A populateCDNResources() 0 6 2
1
<?php
2
3
namespace Dekalee\Cdn77\Query;
4
5
use GuzzleHttp\Client;
6
7
/**
8
 * Class AbstractResourcesAwareQuery
9
 */
10
abstract class AbstractResourcesAwareQuery
11
{
12
    protected $url;
13
    protected $login;
14
    protected $client;
15
    protected $password;
16
    protected $listResourcesQuery;
17
18
    const URL = '';
19
20
    protected $cdnResources;
21
22
    /**
23
     * @param ListResourcesQuery $listResourcesQuery
24
     * @param string      $login
25
     * @param string      $password
26
     * @param string      $url
27
     * @param Client|null $client
28
     */
29 16
    public function __construct(ListResourcesQuery $listResourcesQuery, $login, $password, $url = null, Client $client = null)
30
    {
31 16
        $this->url = null === $url?static::URL: $url;
32 16
        $this->login = $login;
33 16
        $this->client = $client?: new Client();
34 16
        $this->password = $password;
35 16
        $this->listResourcesQuery = $listResourcesQuery;
36 16
    }
37
38
    /**
39
     * Populate CDN resources
40
     */
41 7
    protected function populateCDNResources()
42
    {
43 7
        if (null === $this->cdnResources) {
44 7
            $this->cdnResources = $this->listResourcesQuery->execute();
45 7
        }
46 7
    }
47
}
48