ClosureComparator::assertEquals()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 6
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\Comparator;
13
14
use SebastianBergmann\Comparator\Comparator;
15
use SebastianBergmann\Comparator\ComparisonFailure;
16
17
/**
18
 * Closure comparator.
19
 *
20
 * @author Konstantin Kudryashov <[email protected]>
21
 */
22
final class ClosureComparator extends Comparator
23
{
24
    public function accepts($expected, $actual)
25
    {
26
        return is_object($expected) && $expected instanceof \Closure
27
            && is_object($actual) && $actual instanceof \Closure;
28
    }
29
30
    public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
31
    {
32
        if ($expected !== $actual) {
33
            throw new ComparisonFailure(
34
                $expected,
35
                $actual,
36
                // we don't need a diff
37
                '',
38
                '',
39
                false,
40
                'all closures are different if not identical'
41
            );
42
        }
43
    }
44
}
45