XmlProxySuccessResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 24.32 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
dl 9
loc 37
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setProxyTicket() 0 8 1
A getProxyNode() 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
/**
3
 * Created by PhpStorm.
4
 * User: leo108
5
 * Date: 2016/10/25
6
 * Time: 18:19
7
 */
8
9
namespace Leo108\CAS\Responses;
10
11
use Leo108\CAS\Contracts\Responses\ProxySuccessResponse;
12
use SimpleXMLElement;
13
14
class XmlProxySuccessResponse extends BaseXmlResponse implements ProxySuccessResponse
15
{
16
    /**
17
     * XmlProxySuccessResponse constructor.
18
     */
19 1
    public function __construct()
20
    {
21 1
        parent::__construct();
22 1
        $this->node->addChild('cas:proxySuccess');
23 1
    }
24
25
    /**
26
     * @param string $ticket
27
     * @return $this
28
     */
29 1
    public function setProxyTicket($ticket)
30
    {
31 1
        $proxyNode = $this->getProxyNode();
32 1
        $this->removeByXPath($proxyNode, 'cas:proxyTicket');
33 1
        $proxyNode->addChild('cas:proxyTicket', $ticket);
34
35 1
        return $this;
36
    }
37
38
    /**
39
     * @return SimpleXMLElement
40
     */
41 1 View Code Duplication
    public function getProxyNode()
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...
42
    {
43 1
        $authNodes = $this->node->xpath('cas:proxySuccess');
44 1
        if (count($authNodes) < 1) {
45
            return $this->node->addChild('cas:proxySuccess');
46
        }
47
48 1
        return $authNodes[0];
49
    }
50
}
51