Passed
Pull Request — master (#661)
by
unknown
06:39
created

XmlValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContentType() 0 2 1
A validate() 0 5 2
A setSchema() 0 2 1
1
<?php
2
3
namespace OldSound\RabbitMqBundle\RabbitMq\Validator;
4
5
use DOMDocument;
6
7
class XmlValidator implements ValidatorInterface
8
{
9
    private $schema = null;
10
11
    public function setSchema($schema, $additionalProperties = array()) {
12
        $this->schema = $schema;
13
    }
14
15
    public function validate($msg)
16
    {
17
        $xml = new DOMDocument();
18
        $xml->load($msg);
19
        return $xml->schemaValidate($this->schema) == true ? null : "XML schema validation failed.";
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
20
    }
21
22
    public function getContentType() {
23
        return "application/xml";
24
    }
25
}
26