Code Duplication    Length = 40-48 lines in 2 locations

src/Gabrieljmj/Should/Assert/TheMethod/AbstractMethodAssert.php 1 location

@@ 16-63 (lines=48) @@
13
use Gabrieljmj\Should\Assert\AbstractAssert;
14
use Gabrieljmj\Should\Exception\ShouldException;
15
16
abstract class AbstractMethodAssert extends AbstractAssert
17
{
18
    /**
19
     * @var string|object
20
     */
21
    protected $class;
22
    
23
    /**
24
     * @var string
25
     */
26
    protected $method;
27
    
28
    /**
29
     * @param string|object $class
30
     * @param string        $method
31
     */
32
    public function __construct($class, $method)
33
    {
34
        $this->validateData($class, $method);
35
36
        $this->class = $class;
37
        $this->method = $method;
38
    }
39
40
    /**
41
     * Returns the tested element
42
     *
43
     * @return string
44
     */
45
    public function getTestedElement()
46
    {
47
        $class = $this->classToStr($this->class);
48
        return $class . '::' . $this->method;
49
    }
50
51
    /**
52
     * @param string|object $class
53
     * @param string        $method
54
     */
55
    private function validateData($class, $method)
56
    {
57
        $this->validateClass($class);
58
59
        if (!method_exists($class, $method)) {
60
            ShouldException::methodDoesNotExist($class, $method);
61
        }
62
    }
63
}

src/Gabrieljmj/Should/Assert/TheProperty/AbstractPropertyAssert.php 1 location

@@ 16-55 (lines=40) @@
13
use Gabrieljmj\Should\Assert\AbstractAssert;
14
use Gabrieljmj\Should\Exception\ShouldException;
15
16
abstract class AbstractPropertyAssert extends AbstractAssert
17
{
18
    protected $class;
19
20
    protected $property;
21
22
    /**
23
     * @param string|object $class
24
     * @param string        $property
25
     */
26
    public function __construct($class, $property)
27
    {
28
        $this->validateData($class, $property);
29
30
        $this->class = $class;
31
        $this->property = $property;
32
    }
33
34
    /**
35
     * Returns the tested element
36
     *
37
     * @return string
38
     */
39
    public function getTestedElement()
40
    {
41
        $class = $this->classToStr($this->class);
42
        return $class . '::$' . $this->property;
43
    }
44
45
    private function validateData($class, $property)
46
    {
47
        $this->validateClass($class);
48
49
        $ref = new \ReflectionClass($class);
50
51
        if (!$ref->hasProperty($property)) {
52
            ShouldException::propertyDoesNotExist($class, $property);
53
        }
54
    }
55
}