Completed
Push — d64 ( ca4f4f...a95f31 )
by Welling
02:17
created

ClientRemote::createEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 7
loc 7
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
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
use Directus\Util\ArrayUtils;
13
use Directus\Util\StringUtils;
14
15
/**
16
 * Client Remote
17
 *
18
 * @author Welling Guzmán <[email protected]>
19
 */
20
class ClientRemote extends BaseClientRemote
21
{
22
    /**
23
     * @inheritdoc
24
     */
25 2
    public function getTables(array $params = [])
26
    {
27 2
        return $this->performRequest('GET', static::TABLE_LIST_ENDPOINT);
1 ignored issue
show
Bug Compatibility introduced by
The expression $this->performRequest('G...::TABLE_LIST_ENDPOINT); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 27 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getTables of type Directus\SDK\Response\EntryCollection.
Loading history...
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33 4
    public function getTable($tableName)
34
    {
35 4
        $path = $this->buildPath(static::TABLE_INFORMATION_ENDPOINT, $tableName);
36
37 4
        return $this->performRequest('GET', $path);
1 ignored issue
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 37 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getTable of type Directus\SDK\Response\Entry.
Loading history...
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 2
    public function getColumns($tableName, array $params = [])
44
    {
45 2
        $path = $this->buildPath(static::COLUMN_LIST_ENDPOINT, $tableName);
46
47 2
        return $this->performRequest('GET', $path);
1 ignored issue
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 47 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getColumns of type Directus\SDK\Response\EntryCollection.
Loading history...
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53 2
    public function getColumn($tableName, $columnName)
54
    {
55 2
        $path = $this->buildPath(static::COLUMN_INFORMATION_ENDPOINT, [$tableName, $columnName]);
56
57 2
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 57 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getColumn of type Directus\SDK\Response\Entry.
Loading history...
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63 2
    public function getEntries($tableName, array $options = [])
64
    {
65 2
        $path = $this->buildPath(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...
66
67 2
        return $this->performRequest('GET', $path, ['query' => $options]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('G...('query' => $options)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 67 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getEntries of type Directus\SDK\Response\EntryCollection.
Loading history...
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 2
    public function getEntry($tableName, $id, array $options = [])
74
    {
75 2
        $path = $this->buildPath(static::TABLE_ENTRY_ENDPOINT, [$tableName, $id]);
76
77 2
        return $this->performRequest('GET', $path, ['query' => $options]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('G...('query' => $options)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 77 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getEntry of type Directus\SDK\Response\Entry.
Loading history...
78
    }
79
80
    /**
81
     * @inheritdoc
82
     */
83 2
    public function getUsers(array $params = [])
84
    {
85 2
        return $this->getEntries('directus_users', $params);
86
    }
87
88
    /**
89
     * @inheritdoc
90
     */
91 2
    public function getUser($id, array $params = [])
92
    {
93 2
        return $this->getEntry($id, 'directus_users', $params);
94
    }
95
96
    /**
97
     * @inheritdoc
98
     */
99 2
    public function getGroups()
100
    {
101 2
        return $this->performRequest('GET', static::GROUP_LIST_ENDPOINT);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('G...::GROUP_LIST_ENDPOINT); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 101 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getGroups of type Directus\SDK\Response\EntryCollection.
Loading history...
102
    }
103
104
    /**
105
     * @inheritdoc
106
     */
107 2
    public function getGroup($groupID)
108
    {
109 2
        $path = $this->buildPath(static::GROUP_INFORMATION_ENDPOINT, $groupID);
110
111 2
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 111 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getGroup of type Directus\SDK\Response\Entry.
Loading history...
112
    }
113
114
    /**
115
     * @inheritdoc
116
     */
117 2
    public function getGroupPrivileges($groupID)
118
    {
119 2
        $path = $this->buildPath(static::GROUP_PRIVILEGES_ENDPOINT, $groupID);
120
121 2
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 121 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getGroupPrivileges of type Directus\SDK\Response\EntryCollection.
Loading history...
122
    }
123
124
    /**
125
     * @inheritdoc
126
     */
127 2
    public function getFiles()
128
    {
129 2
        return $this->performRequest('GET', static::FILE_LIST_ENDPOINT);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('G...c::FILE_LIST_ENDPOINT); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 129 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getFiles of type Directus\SDK\Response\EntryCollection.
Loading history...
130
    }
131
132
    /**
133
     * @inheritdoc
134
     */
135 2
    public function getFile($fileID)
136
    {
137 2
        $path = $this->buildPath(static::FILE_INFORMATION_ENDPOINT, $fileID);
138
139 2
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 139 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getFile of type Directus\SDK\Response\Entry.
Loading history...
140
    }
141
142
    /**
143
     * @inheritdoc
144
     */
145 2
    public function getSettings()
146
    {
147 2
        return $this->performRequest('GET', static::SETTING_LIST_ENDPOINT);
148
    }
149
150
    /**
151
     * @inheritdoc
152
     */
153 2
    public function getSettingsByCollection($collectionName)
154
    {
155 2
        $path = $this->buildPath(static::SETTING_COLLECTION_ENDPOINT, $collectionName);
156
157 2
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 157 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInt...getSettingsByCollection of type Directus\SDK\Response\EntryCollection.
Loading history...
158
    }
159
160
    /**
161
     * @inheritdoc
162
     */
163
    public function getMessages($userId)
164
    {
165
        $path = $this->buildPath(static::MESSAGES_USER_ENDPOINT, $userId);
166
167
        return $this->performRequest('GET', $path);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('GET', $path); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\Entry to the return on line 167 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::getMessages of type Directus\SDK\Response\EntryCollection.
Loading history...
168
    }
169
170
    /**
171
     * @inheritdoc
172
     */
173 View Code Duplication
    public function createEntry($tableName, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
174
    {
175
        $path = $this->buildPath(static::TABLE_ENTRY_CREATE_ENDPOINT, $tableName);
176
        $data = $this->processData($tableName, $data);
177
178
        return $this->performRequest('POST', $path, ['body' => $data]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 178 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createEntry of type Directus\SDK\Response\Entry.
Loading history...
179
    }
180
181
    /**
182
     * @inheritdoc
183
     */
184 View Code Duplication
    public function updateEntry($tableName, $id, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
185
    {
186
        $path = $this->buildPath(static::TABLE_ENTRY_UPDATE_ENDPOINT, [$tableName, $id]);
187
        $data = $this->processData($tableName, $data);
188
189
        return $this->performRequest('PUT', $path, ['body' => $data]);
190
    }
191
192
    /**
193
     * @inheritdoc
194
     */
195
    public function deleteEntry($tableName, $id)
196
    {
197
        $path = $this->buildPath(static::TABLE_ENTRY_DELETE_ENDPOINT, [$tableName, $id]);
198
199
        return $this->performRequest('DELETE', $path);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->performRequest('DELETE', $path); (Directus\SDK\Response\En...ctus\SDK\Response\Entry) is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::deleteEntry of type integer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
200
    }
201
202
    /**
203
     * @inheritdoc
204
     */
205
    public function createUser(array $data)
206
    {
207
        return $this->createEntry('directus_users', $data);
208
    }
209
210
    /**
211
     * @inheritdoc
212
     */
213
    public function updateUser($id, array $data)
214
    {
215
        return $this->updateEntry('directus_users', $id, $data);
216
    }
217
218
    /**
219
     * @inheritdoc
220
     */
221
    public function deleteUser($ids)
222
    {
223
        return $this->deleteEntry('directus_users', $ids);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->deleteEntr...directus_users', $ids); (Directus\SDK\Response\En...ctus\SDK\Response\Entry) is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::deleteUser of type integer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
224
    }
225
226
    /**
227
     * @inheritdoc
228
     */
229
    public function createFile(File $file)
230
    {
231
        $data = $this->processFile($file);
232
233
        return $this->performRequest('POST', static::FILE_CREATE_ENDPOINT, ['body' => $data]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 233 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createFile of type Directus\SDK\Response\Entry.
Loading history...
234
    }
235
236
    /**
237
     * @inheritdoc
238
     */
239
    public function updateFile($id, array $data)
240
    {
241
        return $this->updateEntry('directus_files', $id, $data);
242
    }
243
244
    /**
245
     * @inheritdoc
246
     */
247
    public function deleteFile($id)
248
    {
249
        return $this->deleteEntry('directus_files', $id);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->deleteEntry('directus_files', $id); (Directus\SDK\Response\En...ctus\SDK\Response\Entry) is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::deleteFile of type integer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
250
    }
251
252
    public function createPreferences($data)
253
    {
254
        $this->requiredAttributes(['title', 'table_name'], $data);
255
256
        $tableName = ArrayUtils::get($data, 'table_name');
257
        $path = $this->buildPath(static::TABLE_PREFERENCES_ENDPOINT, $tableName);
258
        $data = $this->processData($tableName, $data);
259
260
        return $this->performRequest('POST', $path, ['body' => $data]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 260 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createPreferences of type Directus\SDK\Response\Entry.
Loading history...
261
    }
262
263
    /**
264
     * @inheritdoc
265
     */
266
    public function createBookmark($data)
267
    {
268
        $preferences = $this->createPreferences(ArrayUtils::pick($data, [
269
            'title', 'table_name', 'sort', 'status', 'search_string', 'sort_order', 'columns_visible'
270
        ]));
271
272
        $title = $preferences->title;
0 ignored issues
show
Documentation introduced by
The property title does not exist on object<Directus\SDK\Response\Entry>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
273
        $tableName = $preferences->table_name;
0 ignored issues
show
Documentation introduced by
The property table_name does not exist on object<Directus\SDK\Response\Entry>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
274
        $bookmarkData = [
275
            'section' => 'search',
276
            'title' => $title,
277
            'url' => 'tables/' . $tableName . '/pref/' . $title
278
        ];
279
280
        $path = $this->buildPath(static::TABLE_BOOKMARKS_CREATE_ENDPOINT);
281
        $bookmarkData = $this->processData($tableName, $bookmarkData);
282
283
        return $this->performRequest('POST', $path, ['body' => $bookmarkData]);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...dy' => $bookmarkData)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 283 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createBookmark of type Directus\SDK\Response\Entry.
Loading history...
284
    }
285
286
    /**
287
     * @inheritdoc
288
     */
289
    public function createColumn($data)
290
    {
291
        $data = $this->parseColumnData($data);
292
293
        return $this->performRequest('POST', $this->buildPath(static::COLUMN_CREATE_ENDPOINT, $data['table_name']), [
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 293 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createColumn of type Directus\SDK\Response\Entry.
Loading history...
294
            'body' => $data
295
        ]);
296
    }
297
298
    /**
299
     * @inheritdoc
300
     */
301
    public function createGroup(array $data)
302
    {
303
        return $this->performRequest('POST', static::GROUP_CREATE_ENDPOINT, [
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 303 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createGroup of type Directus\SDK\Response\Entry.
Loading history...
304
            'body' => $data
305
        ]);
306
    }
307
308
    /**
309
     * @inheritdoc
310
     */
311
    public function createMessage(array $data)
312
    {
313
        $this->requiredAttributes(['from', 'message', 'subject'], $data);
314
        $this->requiredOneAttribute(['to', 'toGroup'], $data);
315
316
        $data['recipients'] = $this->getMessagesTo($data);
317
        ArrayUtils::remove($data, ['to', 'toGroup']);
318
319
        return $this->performRequest('POST', static::MESSAGES_CREATE_ENDPOINT, [
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 319 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createMessage of type Directus\SDK\Response\Entry.
Loading history...
320
            'body' => $data
321
        ]);
322
    }
323
324
    /**
325
     * @inheritdoc
326
     */
327
    public function sendMessage(array $data)
328
    {
329
        return $this->createMessage($data);
330
    }
331
332
    /**
333
     * @inheritdoc
334
     */
335
    public function createPrivileges(array $data)
336
    {
337
        $this->requiredAttributes(['group_id', 'table_name'], $data);
338
339
        return $this->performRequest('POST', static::GROUP_PRIVILEGES_CREATE_ENDPOINT, [
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 339 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createPrivileges of type Directus\SDK\Response\Entry.
Loading history...
340
            'body' => $data
341
        ]);
342
    }
343
344
    public function createTable($name, array $params = [])
345
    {
346
        $data = [
347
            'addTable' => true,
348
            'table_name' => $name
349
        ];
350
351
        return $this->performRequest('POST', static::TABLE_CREATE_ENDPOINT, [
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->performRequest('P...rray('body' => $data)); of type Directus\SDK\Response\En...ctus\SDK\Response\Entry adds the type Directus\SDK\Response\EntryCollection to the return on line 351 which is incompatible with the return type declared by the interface Directus\SDK\RequestsInterface::createTable of type Directus\SDK\Response\Entry.
Loading history...
352
            'body' => $data
353
        ]);
354
    }
355
}
356