Completed
Pull Request — master (#90)
by
unknown
03:03
created

XmlCheckRule::doValidation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 1
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace whm\Smoke\Rules\Xml;
4
5
use whm\Smoke\Http\Response;
6
use whm\Smoke\Rules\StandardRule;
7
8
/**
9
 * This rule checks if the found XML is valide.
10
 */
11
class XmlCheckRule extends StandardRule
12
{
13
    public function doValidation(Response $response)
14
    {
15
        $domDocument = new \DOMDocument();
16
        $success = @$domDocument->loadXML((string) $response->getBody());  // true/false
17
18
        if (!$success) {
19
            throw new \RuntimeException('XML called from "' . $response->getUri() . '" is not well-formed...');
20
        }
21
    }
22
}
23