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

AbstractClient::createResponseFromData()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
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
}