StandardSynopsis::detectType()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 4
nc 4
nop 1
1
<?php
2
3
namespace TheIconic\Synopsis;
4
5
/**
6
 * represents anything not represented by any of the other synopsis classes
7
 *
8
 * @package TheIconic\Synopsis
9
 */
10
class StandardSynopsis extends AbstractSynopsis
11
{
12
    /**
13
     * @param $value
14
     * @param $depth
15
     */
16
    public function process($value, $depth)
17
    {
18
        parent::process($value, $depth);
19
20
        $this->type = $this->detectType($value);
21
    }
22
23
    /**
24
     * @param $value
25
     * @return string
26
     */
27
    protected function detectType($value)
28
    {
29
        if ($value === null) {
30
            $type = 'null';
31
        } else if (is_object($value)) {
32
            $type = get_class($value);
33
        } else if (is_resource($value)) {
34
            $type = sprintf('%s resource', get_resource_type($value));
35
        } else {
36
            $type = gettype($value);
37
        }
38
39
        return $type;
40
    }
41
}
42