Completed
Push — d64 ( b460e4...2ffd1a )
by Welling
03:33
created

ClientRemote::getTables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Directus – <http://getdirectus.com>
5
 *
6
 * @link      The canonical repository – <https://github.com/directus/directus>
7
 * @copyright Copyright 2006-2016 RANGER Studio, LLC – <http://rangerstudio.com>
8
 * @license   GNU General Public License (v3) – <http://www.gnu.org/copyleft/gpl.html>
9
 */
10
11
namespace Directus\SDK;
12
13
/**
14
 * Client Remote
15
 *
16
 * @author Welling Guzmán <[email protected]>
17
 */
18
class ClientRemote extends BaseClientRemote implements RequestsInterface
19
{
20
    protected $baseEndpoint = 'http://localhost/api';
21
    protected $hostedBaseEndpointFormat = 'https://%s.directus.io/api';
22
23 2
    public function getTables(array $params = [])
24
    {
25 2
        return $this->performRequest('GET', static::TABLE_LIST_ENDPOINT);
26
    }
27
28 4
    public function fetchTableInfo($tableName)
29
    {
30 4
        return $this->performRequest('GET', static::TABLE_INFORMATION_ENDPOINT, $tableName);
31
    }
32
33
    public function getColumns(array $params = [])
34
    {
35
        throw new \Exception('Endpoint not defined yet');
36
    }
37
38 2
    public function getTableColumns($tableName, array $params = [])
39
    {
40 2
        return $this->performRequest('GET', static::COLUMN_LIST_ENDPOINT, $tableName);
41
    }
42
43 2
    public function fetchColumnInfo($tableName, $columnName)
44
    {
45 2
        return $this->performRequest('GET', static::COLUMN_INFORMATION_ENDPOINT, [$tableName, $columnName]);
46
    }
47
48 2
    public function getEntries($tableName, array $options = [])
49
    {
50 2
        return $this->performRequest('GET', static::TABLE_ENTRIES_ENDPOINT, $tableName);
0 ignored issues
show
Documentation introduced by
$tableName is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
    }
52
53 2
    public function getEntry($id, $tableName, array $options = [])
54
    {
55 2
        return $this->performRequest('GET', static::TABLE_ENTRY_ENDPOINT, [$tableName, $id]);
56
    }
57
58
    public function getUsers(array $params = [])
59
    {
60
        return $this->getEntries('directus_users', $params);
61
    }
62
63
    public function getUser($id, array $params = [])
64
    {
65
        return $this->getEntry($id, 'directus_users', $params);
66
    }
67
68 2
    public function fetchGroups()
69
    {
70 2
        return $this->performRequest('GET', static::GROUP_LIST_ENDPOINT);
71
    }
72
73 2
    public function fetchGroupInfo($groupID)
74
    {
75 2
        return $this->performRequest('GET', static::GROUP_INFORMATION_ENDPOINT, $groupID);
76
    }
77
78 2
    public function fetchGroupPrivileges($groupID)
79
    {
80 2
        return $this->performRequest('GET', static::GROUP_PRIVILEGES_ENDPOINT, $groupID);
81
    }
82
83 2
    public function fetchFiles()
84
    {
85 2
        return $this->performRequest('GET', static::FILE_LIST_ENDPOINT);
86
    }
87
88 2
    public function fetchFileInfo($fileID)
89
    {
90 2
        return $this->performRequest('GET', static::FILE_INFORMATION_ENDPOINT, $fileID);
91
    }
92
93 2
    public function fetchSettings()
94
    {
95 2
        return $this->performRequest('GET', static::SETTING_LIST_ENDPOINT);
96
    }
97
98 2
    public function fetchSettingCollection($collectionName)
99
    {
100 2
        return $this->performRequest('GET', static::SETTING_COLLECTION_ENDPOINT, $collectionName);
101
    }
102
}
103