Completed
Pull Request — master (#120)
by Gorka
03:29
created

CollectionMatcher::matches()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Kreta\SharedKernel\Tests\Matchers;
4
5
use Kreta\SharedKernel\Domain\Model\Collection;
6
use PhpSpec\Exception\Example\FailureException;
7
use PhpSpec\Matcher\BasicMatcher;
8
9
class CollectionMatcher extends BasicMatcher
10
{
11
    protected function matches($subject, array $arguments)
12
    {
13
        return $subject->toArray() === $arguments[0];
14
    }
15
16
    protected function getFailureException($name, $subject, array $arguments)
17
    {
18
        return new FailureException(
19
            'Expected to match Collection but it doesn`t'
20
        );
21
    }
22
23
    protected function getNegativeFailureException($name, $subject, array $arguments)
24
    {
25
        return new FailureException(
26
            'Expected not to match Collection but it does'
27
        );
28
    }
29
30
    public function supports($name, $subject, array $arguments)
31
    {
32
        return $name === 'returnCollection' && $subject instanceof Collection;
33
    }
34
35
}
36