Test Failed
Push — master ( 72a6c5...9329b7 )
by Arun
03:52
created

TypeMatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matches() 0 4 2
1
<?php
2
3
namespace DeepCopy\TypeMatcher;
4
5
/**
6
 * TypeMatcher class
7
 */
8
class TypeMatcher
9
{
10
    /**
11
     * @var string
12
     */
13
    private $type;
14
15
    /**
16
     * @param string $type
17
     */
18
    public function __construct($type)
19
    {
20
        $this->type = $type;
21
    }
22
23
    /**
24
     * @param $element
25
     * @return boolean
26
     */
27
    public function matches($element)
28
    {
29
        return is_object($element) ? is_a($element, $this->type) : gettype($element) === $this->type;
30
    }
31
}
32