Completed
Push — master ( d54351...6ce5d4 )
by Rafael
03:34
created

PropertyMatcherTester   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 27.91 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 12
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testMatch() 12 18 3
buildMatcher() 0 1 ?
getEquals() 0 1 ?
getNotEquals() 0 1 ?

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Tests\PropertyMatcher;
11
12
use Rafrsr\LibArray2Object\PropertyMatcher\PropertyMatcherInterface;
13
14
/**
15
 * Class PropertyMatcherTester
16
 */
17
abstract class PropertyMatcherTester extends \PHPUnit_Framework_TestCase
18
{
19
20
    public function testMatch()
21
    {
22
        $matcher = $this->buildMatcher();
23
24 View Code Duplication
        foreach ($this->getEquals() as $prop => $given) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
            $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
26
            $property->expects(static::any())->method('getName')->willReturn($prop);
27
            $msg = sprintf("property '%s' not match with '%s'", $prop, $given);
28
            static::assertTrue($matcher->match($property, $given), $msg);
29
        }
30
31 View Code Duplication
        foreach ($this->getNotEquals() as $prop => $given) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
            $property = static::getMockBuilder(\ReflectionProperty::class)->disableOriginalConstructor()->getMock();
33
            $property->expects(static::any())->method('getName')->willReturn($prop);
34
            $msg = sprintf("property '%s' match with '%s'", $prop, $given);
35
            static::assertFalse($matcher->match($property, $given), $msg);
36
        }
37
    }
38
39
    /**
40
     * buildMatcher
41
     *
42
     * @return PropertyMatcherInterface
43
     */
44
    abstract public function buildMatcher();
45
46
    /**
47
     * getEquals
48
     *
49
     * @return array
50
     */
51
    abstract public function getEquals();
52
53
    /**
54
     * getNotEquals
55
     *
56
     * @return array
57
     */
58
    abstract public function getNotEquals();
59
}