Completed
Push — master ( 9a1097...9d1cce )
by Nate
04:06
created

Transformer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 20
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isTransformer() 0 4 2
A isTransformerClass() 0 4 2
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 $transformer
22
     * @return bool
23
     */
24 2
    public static function isTransformer($transformer)
25
    {
26 2
        return is_callable($transformer) || $transformer instanceof TransformerInterface;
27
    }
28
29
    /**
30
     * @param $transformer
31
     * @return bool
32
     */
33
    public static function isTransformerClass($transformer)
34
    {
35
        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...
36
    }
37
}
38