AuthXmlResponse::getXpathFaultString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Fns\Auth;
5
6
use SimpleXMLElement;
7
8
class AuthXmlResponse extends SimpleXMLElement
9
{
10
    private function getXpathFaultString() : string
11
    {
12
        return '//ns2:AuthResponse/ns2:Fault/ns2:Message/text()';
13
    }
14
15
    private function getXpathTokenString() : string
16
    {
17
        return  '//ns2:AuthResponse/ns2:Result/ns2:Token/text()';
18
    }
19
20
    private function getXpathExpireTimeString() : string
21
    {
22
        return  '//ns2:AuthResponse/ns2:Result/ns2:ExpireTime/text()';
23
    }
24
25
    public function isError() : bool
26
    {
27
        return !empty($this->xpath($this->getXpathFaultString()));
28
    }
29
30
    public function getToken() : string
31
    {
32
        return (string)$this->xpath($this->getXpathTokenString())[0];
33
    }
34
35
    public function getTime() : string
36
    {
37
        return (string)$this->xpath($this->getXpathExpireTimeString())[0];
38
    }
39
}
40