Completed
Push — master ( 68f942...d69058 )
by Rafał
18:18
created

ParentTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 24
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getParentDocument() 0 4 1
A getParent() 0 4 1
A setParentDocument() 0 4 1
A setParent() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\MultiTenancyBundle\spec;
15
16
use Doctrine\ODM\PHPCR\HierarchyInterface;
17
18
class ParentTest implements HierarchyInterface
19
{
20
    protected $parent;
21
22
    public function getParentDocument()
23
    {
24
        return $this->parent;
25
    }
26
27
    public function getParent()
28
    {
29
        $this->getParentDocument();
0 ignored issues
show
Unused Code introduced by
The call to the method SWP\Bundle\MultiTenancyB...st::getParentDocument() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
30
    }
31
32
    public function setParentDocument($parent)
33
    {
34
        $this->parent = $parent;
35
    }
36
37
    public function setParent($parent)
38
    {
39
        $this->setParentDocument($parent);
40
    }
41
}
42