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

XmlValidator::setSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 2
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
}