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.

MultiFilingService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 28.33 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 17
loc 60
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addObjectToFolder() 0 19 3
A removeObjectFromFolder() 17 17 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\MultiFilingServiceInterface;
16
17
/*
18
 * MultiFiling Service Browser Binding client.
19
 */
20
class MultiFilingService extends AbstractBrowserBindingService implements MultiFilingServiceInterface
21
{
22
    /**
23
     * Adds an existing fileable non-folder object to a folder.
24
     *
25
     * @param string $repositoryId The identifier for the repository.
26
     * @param string $objectId The identifier for the object.
27
     * @param string $folderId The folder into which the object is to be filed.
28
     * @param boolean $allVersions Add all versions of the object to the folder if the repository
29
     *     supports version-specific filing. Defaults to <code>true</code>.
30
     * @param ExtensionDataInterface|null $extension
31
     */
32
    public function addObjectToFolder(
33
        $repositoryId,
34
        $objectId,
35
        $folderId,
36
        $allVersions = true,
37
        ExtensionDataInterface $extension = null
38
    )
39
    {
40
        $url = $this->getObjectUrl($repositoryId, $objectId);
41
42
        $queryArray = [
43
            Constants::CONTROL_CMISACTION => Constants::CMISACTION_ADD_OBJECT_TO_FOLDER,
44
            Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
45
            Constants::PARAM_FOLDER_ID => $folderId,
46
            Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false',
47
        ];
48
49
        $this->post($url, $queryArray);
50
    }
51
52
    /**
53
     * Removes an existing fileable non-folder object from a folder.
54
     *
55
     * @param string $repositoryId The identifier for the repository.
56
     * @param string $objectId The identifier for the object.
57
     * @param string|null $folderId The folder from which the object is to be removed.
58
     *      If no value is specified, then the repository MUST remove the object from all folders in which it is
59
     *      currently filed.
60
     * @param ExtensionDataInterface|null $extension
61
     */
62 View Code Duplication
    public function removeObjectFromFolder(
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...
63
        $repositoryId,
64
        $objectId,
65
        $folderId = null,
66
        ExtensionDataInterface $extension = null
67
    )
68
    {
69
        $url = $this->getObjectUrl($repositoryId, $objectId);
70
71
        $queryArray = [
72
            Constants::CONTROL_CMISACTION => Constants::CMISACTION_REMOVE_OBJECT_FROM_FOLDER,
73
            Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false',
74
            Constants::PARAM_FOLDER_ID => $folderId,
75
        ];
76
77
        $this->post($url, $queryArray);
78
    }
79
}
80