Kint_Parser_Timestamp   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypes() 0 4 1
A getTriggers() 0 4 1
B parse() 0 22 6
1
<?php
2
3
class Kint_Parser_Timestamp extends Kint_Parser_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Parser_Timestamp does not seem to conform to the naming convention (^[A-Z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
4
{
5
    public static $blacklist = array(
6
        2147483648,
7
        2147483647,
8
        1073741824,
9
        1073741823,
10
    );
11
12
    public function getTypes()
13
    {
14
        return array('string', 'integer');
15
    }
16
17
    public function getTriggers()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
18
    {
19
        return Kint_Parser::TRIGGER_SUCCESS;
20
    }
21
22
    public function parse(&$var, Kint_Object &$o, $trigger)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
23
    {
24
        if (is_string($var) && !ctype_digit($var)) {
25
            return;
26
        }
27
28
        if (in_array($var, self::$blacklist)) {
29
            return;
30
        }
31
32
        $len = strlen($var);
33
34
        // Guess for anything between March 1973 and November 2286
35
        if ($len === 9 || $len === 10) {
36
            // If it's an int or string that's this short it probably has no other meaning
37
            // Additionally it's highly unlikely the shortValue will be clipped for length
38
            // If you're writing a plugin that interferes with this, just put your
39
            // parser plugin further down the list so that it gets loaded afterwards.
40
            $o->value->label = 'Timestamp';
41
            $o->value->hints[] = 'timestamp';
42
        }
43
    }
44
}
45