ParseResponse::normalizeResponse()   A
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 5
eloc 9
c 2
b 0
f 1
nc 16
nop 1
dl 0
loc 14
ccs 10
cts 10
cp 1
crap 5
rs 9.6111
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