XmlProxySuccessResponse::getProxyNode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 9
loc 9
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.9666
c 0
b 0
f 0
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