ParseResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 10
c 2
b 0
f 1
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizeResponse() 0 14 5
1
<?php
2
3
namespace Srmklive\Dropbox;
4
5
trait ParseResponse
6
{
7
    /**
8
     * Parse response from Dropbox.
9
     *
10
     * @param array|\Psr\Http\Message\ResponseInterface $response
11
     *
12
     * @return array
13
     */
14 10
    protected function normalizeResponse($response)
15
    {
16 10
        $normalizedPath = ltrim($this->removePathPrefix($response['path_display']), '/');
0 ignored issues
show
Bug introduced by
It seems like removePathPrefix() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        $normalizedPath = ltrim($this->/** @scrutinizer ignore-call */ removePathPrefix($response['path_display']), '/');
Loading history...
17
18 10
        $normalizedResponse = ['path' => $normalizedPath];
19 10
        $normalizedResponse['timestamp'] = isset($response['server_modified']) ?
20 10
            strtotime($response['server_modified']) : null;
21 10
        $normalizedResponse['size'] = isset($response['size']) ? $response['size'] : null;
22 10
        $normalizedResponse['bytes'] = isset($response['size']) ? $response['size'] : null;
23
24 10
        $type = ($response['.tag'] === 'folder' ? 'dir' : 'file');
25 10
        $normalizedResponse['type'] = $type;
26
27 10
        return array_filter($normalizedResponse);
28
    }
29
}
30