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

IsInstanceOf::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 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