Completed
Push — master ( 1358d6...984c1e )
by Karsten
01:40
created

IsInstanceOf   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 2
A isApplicable() 0 4 2
1
<?php
2
/**
3
 * File was created 29.05.2015 21:06
4
 *
5
 * @author Karsten J. Gerber <[email protected]>
6
 */
7
namespace PeekAndPoke\Component\Psi\Psi;
8
9
use PeekAndPoke\Component\Psi\Functions\Unary\AbstractParameterizedUnaryFunction;
10
11
/**
12
 * IsInstanceOf
13
 *
14
 * @author Karsten J. Gerber <[email protected]>
15
 */
16
class IsInstanceOf extends AbstractParameterizedUnaryFunction
17
{
18
    /**
19
     * @param mixed $input
20
     *
21
     * @return bool
22
     */
23 20
    public function __invoke($input)
24
    {
25 20
        $val = $this->getValue();
26
27 20
        return $this->isApplicable($val) && ($input instanceof $val);
28
    }
29
30
    /**
31
     * @param $val
32
     * @return bool
33
     */
34 20
    private function isApplicable($val)
35
    {
36 20
        return is_string($val) || is_object($val);
37
    }
38
}
39