populateCDNResources()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 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