Passed
Pull Request — master (#661)
by
unknown
17:46 queued 07:49
created

XmlValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setSchema() 0 2 1
A isValid() 0 5 2
A getContentType() 0 2 1
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
}