Completed
Branch dev (35fed3)
by Dennis
02:04
created

WzClassificationFile::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 3
nop 1
crap 4
1
<?php
2
3
/**
4
 * (c) Dennis Meckel
5
 *
6
 * For the full copyright and license information,
7
 * please view the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Rayne\wz2008\Graph\Parser;
11
12
use InvalidArgumentException;
13
14
class WzClassificationFile extends WzClassification
15
{
16
    /**
17
     * @param string $xmlFile
18
     * @throws InvalidArgumentException Unreadable or invalid file.
19
     */
20 18
    public function __construct($xmlFile)
21
    {
22 18
        if (!is_file($xmlFile) || !is_readable($xmlFile)) {
23 3
            throw new InvalidArgumentException(
24 3
                sprintf("Can't read file `%s`.", $xmlFile));
25
        }
26
27 15
        $xml = @simplexml_load_file($xmlFile);
28
29 15
        if (!$xml) {
30 4
            throw new InvalidArgumentException(
31 3
                sprintf("Invalid XML file `%s`.", $xmlFile));
32
        }
33
34 12
        parent::__construct($xml);
35 12
    }
36
}
37