Passed
Push — master ( 9a5e09...c4d015 )
by Faiz
06:53
created

XML::pathToXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace FaizShukri\Quran\Supports;
4
5
class XML
6
{
7
    private $xml;
8
9 64
    public function __construct($xmlPath)
10
    {
11 64
        $this->xml = $this->pathToXML($xmlPath);
12 32
    }
13
14 62
    public function find($xpath)
15
    {
16 62
        $xml = new \SimpleXMLElement($this->xml);
17
18 62
        return $xml->xpath($xpath);
19
    }
20
21 64
    public function pathToXML($xmlPath)
22
    {
23 64
        $xml = fopen($xmlPath, 'r');
24 64
        $res = fread($xml, filesize($xmlPath));
25 64
        fclose($xml);
26
27 64
        return $res;
28
    }
29
}
30