GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

NavigationService::getFolderTree()   B
last analyzed

Complexity

Conditions 6
Paths 4

Size

Total Lines 36

Duplication

Lines 36
Ratio 100 %

Code Coverage

Tests 19
CRAP Score 6

Importance

Changes 0
Metric Value
dl 36
loc 36
ccs 19
cts 19
cp 1
rs 8.7217
c 0
b 0
f 0
cc 6
nc 4
nop 9
crap 6

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
namespace Dkd\PhpCmis\Bindings\Browser;
3
4
/*
5
 * This file is part of php-cmis-client.
6
 *
7
 * (c) Sascha Egerer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
use Dkd\PhpCmis\Constants;
14
use Dkd\PhpCmis\Data\ExtensionDataInterface;
15
use Dkd\PhpCmis\Data\ObjectDataInterface;
16
use Dkd\PhpCmis\Data\ObjectInFolderContainerInterface;
17
use Dkd\PhpCmis\Data\ObjectInFolderListInterface;
18
use Dkd\PhpCmis\Data\ObjectListInterface;
19
use Dkd\PhpCmis\Data\ObjectParentDataInterface;
20
use Dkd\PhpCmis\Enum\IncludeRelationships;
21
use Dkd\PhpCmis\NavigationServiceInterface;
22
23
/**
24
 * Navigation Service Browser Binding client.
25
 */
26
class NavigationService extends AbstractBrowserBindingService implements NavigationServiceInterface
27
{
28
    /**
29
     * Gets the list of documents that are checked out that the user has access to.
30
     *
31
     * @param string $repositoryId the identifier for the repository
32
     * @param string $folderId the identifier for the folder
33
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
34
     *      returned by the repository (default is repository specific)
35
     * @param string|null $orderBy a comma-separated list of query names that define the order of the result set.
36
     *      Each query name must be followed by the ascending modifier "ASC" or the descending modifier "DESC"
37
     *      (default is repository specific)
38
     * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
39
     *      actions for each object in the result set (default is <code>false</code>)
40
     * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
41
     *      participate must be returned (default is <code>IncludeRelationships::NONE</code>)
42
     * @param string $renditionFilter indicates what set of renditions the repository must return whose kind
43
     *      matches this filter (default is "cmis:none")
44
     * @param integer|null $maxItems the maximum number of items to return in a response
45
     *      (default is repository specific)
46
     * @param integer $skipCount number of potential results that the repository MUST skip/page over before
47
     *      returning any results (default is 0)
48
     * @param ExtensionDataInterface|null $extension
49
     * @return ObjectListInterface
50
     */
51 2
    public function getCheckedOutDocs(
52
        $repositoryId,
53
        $folderId,
54
        $filter = null,
55
        $orderBy = null,
56
        $includeAllowableActions = false,
57
        IncludeRelationships $includeRelationships = null,
58
        $renditionFilter = Constants::RENDITION_NONE,
59
        $maxItems = null,
60
        $skipCount = 0,
61
        ExtensionDataInterface $extension = null
62
    ) {
63 2
        $url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_CHECKEDOUT);
64 2
        $url->getQuery()->modify(
65
            [
66 2
                Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
67 2
                Constants::PARAM_RENDITION_FILTER => $renditionFilter,
68 2
                Constants::PARAM_SKIP_COUNT => (string) $skipCount,
69 2
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
70 2
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
71 2
            ]
72 2
        );
73
74 2
        if (!empty($filter)) {
75 1
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
76 1
        }
77
78 2
        if (!empty($orderBy)) {
79 1
            $url->getQuery()->modify([Constants::PARAM_ORDER_BY => $orderBy]);
80 1
        }
81
82 2
        if ($maxItems > 0) {
83 1
            $url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
84 1
        }
85
86 2
        if ($includeRelationships !== null) {
87 1
            $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
88 1
        }
89
90 2
        $responseData = (array) $this->readJson($url);
91
92
        // TODO Implement Cache
93 2
        return $this->getJsonConverter()->convertObjectList($responseData);
94
    }
95
96
    /**
97
     * Gets the list of child objects contained in the specified folder.
98
     *
99
     * @param string $repositoryId the identifier for the repository
100
     * @param string $folderId the identifier for the folder
101
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
102
     *      returned by the repository (default is repository specific)
103
     * @param string|null $orderBy a comma-separated list of query names that define the order of the result set.
104
     *      Each query name must be followed by the ascending modifier "ASC" or the descending modifier "DESC"
105
     *      (default is repository specific)
106
     * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
107
     *      actions for each object in the result set (default is <code>false</code>)
108
     * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
109
     *      participate must be returned (default is <code>IncludeRelationships::NONE</code>)
110
     * @param string $renditionFilter indicates what set of renditions the repository must return whose kind
111
     *      matches this filter (default is "cmis:none")
112
     * @param boolean $includePathSegment if <code>true</code>, returns a path segment for each child object for use in
113
     *      constructing that object's path (default is <code>false</code>)
114
     * @param integer|null $maxItems the maximum number of items to return in a response
115
     *      (default is repository specific)
116
     * @param integer $skipCount number of potential results that the repository MUST skip/page over before
117
     *      returning any results (default is 0)
118
     * @param ExtensionDataInterface|null $extension
119
     * @return ObjectInFolderListInterface
120
     */
121 3
    public function getChildren(
122
        $repositoryId,
123
        $folderId,
124
        $filter = null,
125
        $orderBy = null,
126
        $includeAllowableActions = false,
127
        IncludeRelationships $includeRelationships = null,
128
        $renditionFilter = Constants::RENDITION_NONE,
129
        $includePathSegment = false,
130
        $maxItems = null,
131
        $skipCount = 0,
132
        ExtensionDataInterface $extension = null
133
    ) {
134 3
        $url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_CHILDREN);
135 3
        $url->getQuery()->modify(
136
            [
137 3
                Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
138 3
                Constants::PARAM_RENDITION_FILTER => $renditionFilter,
139 3
                Constants::PARAM_PATH_SEGMENT => $includePathSegment ? 'true' : 'false',
140 3
                Constants::PARAM_SKIP_COUNT => (string) $skipCount,
141 3
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
142 3
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
143 3
            ]
144 3
        );
145
146 3
        if (!empty($filter)) {
147 2
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
148 2
        }
149
150 3
        if (!empty($orderBy)) {
151 2
            $url->getQuery()->modify([Constants::PARAM_ORDER_BY => $orderBy]);
152 2
        }
153
154 3
        if ($maxItems > 0) {
155 1
            $url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]);
156 1
        }
157
158 3
        if ($includeRelationships !== null) {
159 2
            $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
160 2
        }
161
162 3
        $responseData = (array) $this->readJson($url);
163
164
        // TODO Implement Cache
165 3
        return $this->getJsonConverter()->convertObjectInFolderList($responseData);
166
    }
167
168
    /**
169
     * Gets the set of descendant objects contained in the specified folder or any of its child folders.
170
     *
171
     * @param string $repositoryId the identifier for the repository
172
     * @param string $folderId the identifier for the folder
173
     * @param integer $depth the number of levels of depth in the folder hierarchy from which to return results
174
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
175
     *      returned by the repository (default is repository specific)
176
     * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
177
     *      actions for each object in the result set (default is <code>false</code>)
178
     * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
179
     *      participate must be returned (default is <code>IncludeRelationships::NONE</code>)
180
     * @param string $renditionFilter indicates what set of renditions the repository must return whose kind
181
     *      matches this filter (default is "cmis:none")
182
     * @param boolean $includePathSegment if <code>true</code>, returns a path segment for each child object for use in
183
     *      constructing that object's path (default is <code>false</code>)
184
     * @param ExtensionDataInterface|null $extension
185
     * @return ObjectInFolderContainerInterface[]
186
     */
187 3 View Code Duplication
    public function getDescendants(
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...
188
        $repositoryId,
189
        $folderId,
190
        $depth,
191
        $filter = null,
192
        $includeAllowableActions = false,
193
        IncludeRelationships $includeRelationships = null,
194
        $renditionFilter = Constants::RENDITION_NONE,
195
        $includePathSegment = false,
196
        ExtensionDataInterface $extension = null
197
    ) {
198 3
        $url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_DESCENDANTS);
199 3
        $url->getQuery()->modify(
200
            [
201 3
                Constants::PARAM_DEPTH => (string) $depth,
202 3
                Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
203 3
                Constants::PARAM_RENDITION_FILTER => $renditionFilter,
204 3
                Constants::PARAM_PATH_SEGMENT => $includePathSegment ? 'true' : 'false',
205 3
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
206 3
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
207 3
            ]
208 3
        );
209
210 3
        if (!empty($filter)) {
211 2
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
212 2
        }
213
214 3
        if ($includeRelationships !== null) {
215 3
            $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
216 3
        }
217
218 3
        $responseData = (array) $this->readJson($url);
219
220
        // TODO Implement Cache
221 3
        return $this->getJsonConverter()->convertDescendants($responseData);
222
    }
223
224
    /**
225
     * Gets the parent folder object for the specified folder object.
226
     *
227
     * @param string $repositoryId the identifier for the repository
228
     * @param string $folderId the identifier for the folder
229
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
230
     *      returned by the repository (default is repository specific)
231
     * @param ExtensionDataInterface|null $extension
232
     * @return ObjectDataInterface
233
     */
234 2
    public function getFolderParent(
235
        $repositoryId,
236
        $folderId,
237
        $filter = null,
238
        ExtensionDataInterface $extension = null
239
    ) {
240 2
        $url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_PARENT);
241 2
        $url->getQuery()->modify(
242
            [
243 2
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
244 2
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
245 2
            ]
246 2
        );
247
248 2
        if (!empty($filter)) {
249 1
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
250 1
        }
251
252 2
        $responseData = (array) $this->readJson($url);
253
254
        // TODO Implement Cache
255 2
        return $this->getJsonConverter()->convertObject($responseData);
256
    }
257
258
    /**
259
     * Gets the set of descendant folder objects contained in the specified folder.
260
     *
261
     * @param string $repositoryId the identifier for the repository
262
     * @param string $folderId the identifier for the folder
263
     * @param integer $depth the number of levels of depth in the folder hierarchy from which to return results
264
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
265
     *      returned by the repository (default is repository specific)
266
     * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
267
     *      actions for each object in the result set (default is <code>false</code>)
268
     * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
269
     *      participate must be returned (default is <code>IncludeRelationships::NONE</code>)
270
     * @param string $renditionFilter indicates what set of renditions the repository must return whose kind
271
     *      matches this filter (default is "cmis:none")
272
     * @param boolean $includePathSegment if <code>true</code>, returns a path segment for each child object for use in
273
     *      constructing that object's path (default is <code>false</code>)
274
     * @param ExtensionDataInterface|null $extension
275
     * @return ObjectInFolderContainerInterface[]
276
     */
277 2 View Code Duplication
    public function getFolderTree(
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...
278
        $repositoryId,
279
        $folderId,
280
        $depth,
281
        $filter = null,
282
        $includeAllowableActions = false,
283
        IncludeRelationships $includeRelationships = null,
284
        $renditionFilter = Constants::RENDITION_NONE,
285
        $includePathSegment = false,
286
        ExtensionDataInterface $extension = null
287
    ) {
288 2
        $url = $this->getObjectUrl($repositoryId, $folderId, Constants::SELECTOR_FOLDER_TREE);
289 2
        $url->getQuery()->modify(
290
            [
291 2
                Constants::PARAM_DEPTH => (string) $depth,
292 2
                Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
293 2
                Constants::PARAM_RENDITION_FILTER => $renditionFilter,
294 2
                Constants::PARAM_PATH_SEGMENT => $includePathSegment ? 'true' : 'false',
295 2
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
296 2
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
297 2
            ]
298 2
        );
299
300 2
        if (!empty($filter)) {
301 1
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
302 1
        }
303
304 2
        if ($includeRelationships !== null) {
305 1
            $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
306 1
        }
307
308 2
        $responseData = (array) $this->readJson($url);
309
310
        // TODO Implement Cache
311 2
        return $this->getJsonConverter()->convertDescendants($responseData);
312
    }
313
314
    /**
315
     * Gets the parent folder(s) for the specified non-folder, fileable object
316
     *
317
     * @param string $repositoryId the identifier for the repository
318
     * @param string $objectId the identifier for the object
319
     * @param string|null $filter a comma-separated list of query names that defines which properties must be
320
     *      returned by the repository (default is repository specific)
321
     * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available
322
     *      actions for each object in the result set (default is <code>false</code>)
323
     * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects
324
     *      participate must be returned (default is <code>IncludeRelationships::NONE</code>)
325
     * @param string $renditionFilter indicates what set of renditions the repository must return whose kind
326
     *      matches this filter (default is "cmis:none")
327
     * @param boolean $includeRelativePathSegment if <code>true</code>, returns a relative path segment for each parent
328
     *      object for use in constructing that object's path (default is <code>false</code>)
329
     * @param ExtensionDataInterface|null $extension
330
     * @return ObjectParentDataInterface[]
331
     */
332 2 View Code Duplication
    public function getObjectParents(
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...
333
        $repositoryId,
334
        $objectId,
335
        $filter = null,
336
        $includeAllowableActions = false,
337
        IncludeRelationships $includeRelationships = null,
338
        $renditionFilter = Constants::RENDITION_NONE,
339
        $includeRelativePathSegment = false,
340
        ExtensionDataInterface $extension = null
341
    ) {
342 2
        $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_PARENTS);
343 2
        $url->getQuery()->modify(
344
            [
345 2
                Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false',
346 2
                Constants::PARAM_RENDITION_FILTER => $renditionFilter,
347 2
                Constants::PARAM_RELATIVE_PATH_SEGMENT => $includeRelativePathSegment ? 'true' : 'false',
348 2
                Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
349 2
                Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat()
350 2
            ]
351 2
        );
352
353 2
        if (!empty($filter)) {
354 1
            $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]);
355 1
        }
356
357 2
        if ($includeRelationships !== null) {
358 1
            $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]);
359 1
        }
360
361 2
        $responseData = (array) $this->readJson($url);
362
363
        // TODO Implement Cache
364 2
        return $this->getJsonConverter()->convertObjectParents($responseData);
365
    }
366
}
367