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

XmlCheckRule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 12
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A doValidation() 0 9 2
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