Failed Conditions
Push — master ( 01c22b...e42c1f )
by Marco
79:13 queued 10s
created

GetVariableType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
dl 0
loc 20
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Exception;
6
7
use function get_class;
8
use function get_resource_type;
9
use function gettype;
10
use function is_bool;
11
use function is_object;
12
use function is_resource;
13
14
final class GetVariableType
15
{
16
    /**
17
     * @param mixed $value
18
     */
19
    public function __invoke($value) : string
20
    {
21
        if (is_object($value)) {
22
            return get_class($value);
23
        }
24
25
        if (is_resource($value)) {
26
            return get_resource_type($value);
27
        }
28
29
        if (is_bool($value)) {
30
            return $value === true ? 'true' : 'false';
31
        }
32
33
        return gettype($value);
34
    }
35
}
36