Completed
Push — master ( f6d369...6b04e5 )
by Nate
02:09
created

Transformer::isCallable()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 2
nc 5
nop 1
crap 4
1
<?php
2
3
/**
4
 * @author    Flipbox Factory
5
 * @copyright Copyright (c) 2017, Flipbox Digital
6
 * @link      https://github.com/flipbox/transform/releases/latest
7
 * @license   https://github.com/flipbox/transform/blob/master/LICENSE
8
 */
9
10
namespace Flipbox\Transform\Helpers;
11
12
use Flipbox\Transform\Transformers\TransformerInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.0.0
17
 */
18
class Transformer
19
{
20
    /**
21
     * @param $item
22
     * @return bool
23
     */
24 2
    public static function isCallable($item)
25
    {
26 2
        return (is_string($item) && function_exists($item)) || (is_object($item) && ($item instanceof \Closure));
27
    }
28
29
    /**
30
     * @param $transformer
31
     * @return bool
32
     */
33 2
    public static function isTransformer($transformer)
34
    {
35 2
        return static::isCallable($transformer) || $transformer instanceof TransformerInterface;
36
    }
37
38
    /**
39
     * @param $transformer
40
     * @return bool
41
     */
42
    public static function isTransformerClass($transformer)
43
    {
44
        return is_string($transformer) && is_subclass_of($transformer, TransformerInterface::class);
1 ignored issue
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Flipbox\Transform\Trans...sformerInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
45
    }
46
}
47