PohodaResponseXML::isOk()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Hexako\Pohoda;
4
5
use Hexako\Exception\FileNotFoundException;
6
7
/**
8
 * Class PohodaResponseXML
9
 * @package Hexako\Pohoda
10
 */
11
class PohodaResponseXML
12
{
13
14
    /**
15
     * @var \SimpleXMLElement
16
     */
17
    protected $xml;
18
19
    /**
20
     * @var array
21
     */
22
    protected $ns = array();
23
    
24
    /**
25
     * State when file was imported successfully
26
     */
27
    const STATE_OK = 'ok';
28
29
    /**
30
     * Create a new PohodaResponseParser Instance
31
     * @param string $filename path to file
32
     * @throws FileNotFoundException
33
     */
34 2
    public function __construct($filename)
35
    {
36 2
        if (!file_exists($filename)) {
37 1
            throw new FileNotFoundException();
38
        }
39 1
        $this->xml = simplexml_load_file($filename);
40 1
        $this->ns = $this->xml->getNameSpaces(true);
41 1
    }
42
43
    /**
44
     * Checks if import was successful
45
     * @return bool
46
     */
47 1
    public function isOk()
48
    {
49 1
        return $this->getState() == static::STATE_OK;
50
    }
51
52
    /**
53
     * Return state of whole file
54
     * @return string
55
     */
56 1
    public function getState()
57
    {
58 1
        return (string) $this->xml['state'];
59
    }
60
}
61