TypeUtils   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 44
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isCurl() 0 4 2
A isGeneratorContainer() 0 4 1
A isGeneratorClosure() 0 5 2
A isFatalThrowable() 0 5 3
1
<?php
2
3
namespace mpyw\Co\Internal;
4
5
class TypeUtils
6
{
7
    /**
8
     * Check if value is a valid cURL handle.
9
     * @param  mixed $value
10
     * @return bool
11
     */
12 33
    public static function isCurl($value)
13 33
    {
14 2
        return is_resource($value) && get_resource_type($value) === 'curl';
15
    }
16
17
    /**
18
     * Check if value is a valid Generator.
19
     * @param  mixed $value
20
     * @return bool
21
     */
22 30
    public static function isGeneratorContainer($value)
23 30
    {
24 30
        return $value instanceof GeneratorContainer;
25
    }
26
27
    /**
28
     * Check if value is a valid Generator closure.
29
     * @param  mixed $value
30
     * @return bool
31
     */
32 34
    public static function isGeneratorClosure($value)
33 34
    {
34 34
        return $value instanceof \Closure
35 34
            && (new \ReflectionFunction($value))->isGenerator();
36
    }
37
38
    /**
39
     * Check if value is Throwable, excluding RuntimeException.
40
     * @param  mixed $value
41
     * @return bool
42
     */
43 9
    public static function isFatalThrowable($value)
44 9
    {
45 9
        return !$value instanceof \RuntimeException
46 9
            && ($value instanceof \Throwable || $value instanceof \Exception);
47
    }
48
}
49