Completed
Push — d64 ( b18498...be696f )
by Welling
24:39 queued 09:01
created

AbstractClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createResponseFromData() 0 10 4
1
<?php
2
3
namespace Directus\SDK;
4
5
use Directus\SDK\Response\EntryCollection;
6
use Directus\SDK\Response\Entry;
7
use Directus\Util\ArrayUtils;
8
9
abstract class AbstractClient implements RequestsInterface
10
{
11
    // @TODO: move to a builder class
12
    protected function createResponseFromData($data)
13
    {
14
        if (isset($data['rows']) || (isset($data['data']) && ArrayUtils::isNumericKeys($data['data']))) {
15
            $response = new EntryCollection($data);
16
        } else {
17
            $response = new Entry($data);
18
        }
19
20
        return $response;
21
    }
22
}