Passed
Pull Request — master (#661)
by
unknown
09:05
created

XmlValidator::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle\RabbitMq;
4
5
use DOMDocument;
6
7
class XmlValidator implements ValidatorInterface
8
{
9
    public $schema = null;
10
11
    public function setSchema($schema, $definitions=null) {
12
        $this->schema = $schema;
13
    }
14
    public function isValid($msg)
15
    {
16
        $xml = new DOMDocument();
17
        $xml->load($msg);
18
        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...
19
    }
20
21
    public function getContentType() {
22
        return "application/xml";
23
    }
24
}