Passed
Push — master ( f8574f...0e1b55 )
by Julien
08:17 queued 05:08
created

XmlCheck::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
4
namespace Pitchart\Phlunit\Checks;
5
6
use PHPUnit\Framework\Assert;
7
use Pitchart\Phlunit\Checks\Mixin\TypeCheck;
8
use Pitchart\Phlunit\Checks\Mixin\WithMessage;
9
use Pitchart\Phlunit\Constraint\Xml\MatchesSchema;
10
use Pitchart\Phlunit\Constraint\Xml\XmlUtility;
11
12
class XmlCheck implements FluentCheck
13
{
14
    use TypeCheck, WithMessage;
15
16
    /**
17
     * @var \DOMDocument
18
     */
19
    private $value;
20
21
    /**
22
     * XmlCheck constructor.
23
     *
24
     * @param string|\DOMDocument $value
25
     */
26 7
    public function __construct($value)
27
    {
28 7
        $this->value = XmlUtility::load($value);
29 7
    }
30
31 2
    public function isEqualTo($expected): self
32
    {
33 2
        Assert::assertXmlStringEqualsXmlString($expected, $this->value, $this->message);
34 2
        return $this;
35
    }
36
37 2
    public function isNotEqualTo($expected): self
38
    {
39 2
        Assert::assertXmlStringNotEqualsXmlString($expected, $this->value, $this->message);
40 2
        return $this;
41
    }
42
43 2
    public function isEqualToFileContent(string $path): self
44
    {
45 2
        Assert::assertXmlStringEqualsXmlFile($path, $this->value, $this->message);
46 2
        return $this;
47
    }
48
49 2
    public function isNotEqualToFileContent(string $path): self
50
    {
51 2
        Assert::assertXmlStringNotEqualsXmlFile($path, $this->value, $this->message);
52 2
        return $this;
53
    }
54
55 3
    public function matchesSchema(string $schema): self
56
    {
57 3
        Assert::assertThat($this->value, new MatchesSchema($schema), $this->message);
58 3
        return $this;
59
    }
60
}
61