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

XmlCheck   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 14
c 1
b 0
f 1
dl 0
loc 47
ccs 18
cts 18
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isNotEqualTo() 0 4 1
A isEqualTo() 0 4 1
A isEqualToFileContent() 0 4 1
A isNotEqualToFileContent() 0 4 1
A matchesSchema() 0 4 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