PhpUnitCompat   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 6
eloc 10
c 4
b 0
f 0
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A expectExceptionMessageMatches() 0 5 2
A assertEqualsCanonicalizing() 0 5 2
A assertMatchesRegularExpression() 0 5 2
1
<?php
2
3
/**
4
 * This file is part of the tarantool/client package.
5
 *
6
 * (c) Eugene Leonovich <[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
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests;
15
16
/**
17
 * Compatibility layer for legacy PHPUnit versions.
18
 */
19
trait PhpUnitCompat
20
{
21
    /**
22
     * TestCase::expectExceptionMessageRegExp() is deprecated since PHPUnit 8.4.
23
     */
24
    public function expectExceptionMessageMatches(string $regularExpression) : void
25
    {
26
        is_callable(parent::class.'::expectExceptionMessageMatches')
27
            ? parent::expectExceptionMessageMatches(...func_get_args())
28
            : parent::expectExceptionMessageRegExp(...func_get_args());
29
    }
30
31
    /**
32
     * Assert::assertEquals()'s $delta, $maxDepth, $canonicalize parameters are deprecated since PHPUnit 8.0.
33
     */
34
    public static function assertEqualsCanonicalizing($expected, $actual, string $message = '') : void
35
    {
36
        is_callable(parent::class.'::assertEqualsCanonicalizing')
37
            ? parent::assertEqualsCanonicalizing($expected, $actual, $message)
38
            : parent::assertEquals($expected, $actual, $message, 0.0, 10, true);
39
    }
40
41
    /**
42
     * Assert::assertRegExp() is deprecated since PHPUnit 9.1.
43
     */
44
    public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = '') : void
45
    {
46
        is_callable(parent::class.'::assertMatchesRegularExpression')
47
            ? parent::assertMatchesRegularExpression(...func_get_args())
48
            : parent::assertRegExp(...func_get_args());
49
    }
50
}
51