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

CollectionMatcher   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A matches() 0 4 1
A getFailureException() 0 6 1
A getNegativeFailureException() 0 6 1
A supports() 0 4 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