ResourceLogQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 33
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 22 3
1
<?php
2
3
namespace Dekalee\Cdn77\Query;
4
5
/**
6
 * Class ResourceLogQuery
7
 */
8
class ResourceLogQuery extends AbstractPurgeQuery implements QueryInterface
0 ignored issues
show
Deprecated Code introduced by
The class Dekalee\Cdn77\Query\AbstractPurgeQuery has been deprecated with message: will be removed in 2.0.0 use AbstractResourcesAwareQuery

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
9
{
10
    const URL = 'https://api.cdn77.com/v2.0/log/details';
11
12
    /**
13
     * @param string|null $resource
14
     *
15
     * @return array
16
     */
17 2
    public function execute($resource = null)
18
    {
19 2
        $this->populateCDNResources();
20
21 2
        foreach ($this->cdnResources as $cdnResource) {
22 2
            if (false !== strpos($cdnResource['cname'], $resource)) {
23 1
                $url = sprintf($this->url . '?login=%s&passwd=%s&cdn_id=%d&period=4&http_status[]=cached&http_status[]=noncached',
24 1
                    $this->login,
25 1
                    $this->password,
26 1
                    $cdnResource['id']
27 1
                );
28
29 1
                $response = $this->client->get($url);
30
31 1
                $responseData = json_decode($response->getBody()->getContents(), true);
32
33 1
                return $responseData['logs'];
34
            }
35 1
        }
36
37 1
        return [];
38
    }
39
40
}
41