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.
Completed
Push — master ( 42c65a...a98f71 )
by
unknown
07:18
created

Relationship   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 55.88 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 2
dl 38
loc 68
ccs 0
cts 22
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSource() 10 10 2
A getTarget() 10 10 2
A getSourceId() 9 9 2
A getTargetId() 9 9 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\DataObjects;
3
4
/**
5
 * This file is part of php-cmis-lib.
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\CmisObject\CmisObjectInterface;
14
use Dkd\PhpCmis\Data\ObjectIdInterface;
15
use Dkd\PhpCmis\Data\RelationshipInterface;
16
use Dkd\PhpCmis\OperationContextInterface;
17
use Dkd\PhpCmis\PropertyIds;
18
19
/**
20
 * Cmis Relationship implementation
21
 */
22
class Relationship extends AbstractFileableCmisObject implements RelationshipInterface
23
{
24
    /**
25
     * Gets the source object using the given OperationContext.
26
     *
27
     * @param OperationContextInterface|null $context
28
     * @return CmisObjectInterface|null If the source object ID is invalid, <code>null</code> will be returned.
29
     */
30 View Code Duplication
    public function getSource(OperationContextInterface $context = null)
31
    {
32
        $sourceId = $this->getSourceId();
33
        if ($sourceId === null) {
34
            return null;
35
        }
36
        $context = $this->ensureContext($context);
37
38
        return $this->getSession()->getObject($sourceId, $context);
39
    }
40
41
    /**
42
     * Gets the target object using the given OperationContext.
43
     *
44
     * @param OperationContextInterface|null $context
45
     * @return CmisObjectInterface If the target object ID is invalid, <code>null</code> will be returned.
46
     */
47 View Code Duplication
    public function getTarget(OperationContextInterface $context = null)
48
    {
49
        $context = $this->ensureContext($context);
50
        $targetId = $this->getTargetId();
51
        if ($targetId === null) {
52
            return null;
53
        }
54
55
        return $this->getSession()->getObject($targetId, $context);
56
    }
57
58
    /**
59
     * Returns the source ID of this CMIS relationship (CMIS property cmis:sourceId).
60
     *
61
     * @return ObjectIdInterface|null the source ID or <code>null</code> if the property hasn't been requested,
62
     * hasn't been provided by the repository, or the property value isn't set
63
     */
64 View Code Duplication
    public function getSourceId()
65
    {
66
        $sourceId = $this->getPropertyValue(PropertyIds::SOURCE_ID);
67
        if (empty($sourceId)) {
68
            return null;
69
        }
70
71
        return $this->getSession()->createObjectId($sourceId);
72
    }
73
74
    /**
75
     * Returns the target ID of this CMIS relationship (CMIS property cmis:targetId).
76
     *
77
     * @return ObjectIdInterface the target ID or <code>null</code> if the property hasn't been requested,
78
     * hasn't been provided by the repository, or the property value isn't set
79
     */
80 View Code Duplication
    public function getTargetId()
81
    {
82
        $targetId = $this->getPropertyValue(PropertyIds::TARGET_ID);
83
        if (empty($targetId)) {
84
            return null;
85
        }
86
87
        return $this->getSession()->createObjectId($targetId);
88
    }
89
}
90