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

WzClassificationFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 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