Xhgui_Util   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A simpleUrl() 0 8 2
A generateId() 0 4 1
1
<?php
2
3
class Xhgui_Util
4
{
5
    /**
6
     * Creates a simplified URL given a standard URL.
7
     * Does the following transformations:
8
     *
9
     * - Remove numeric values after =.
10
     *
11
     * @param string $url
12
     * @return string
13
     */
14
    public static function simpleUrl($url)
15
    {
16
        $callable = Xhgui_Config::read('profiler.simple_url');
17
        if (is_callable($callable)) {
18
            return call_user_func($callable, $url);
19
        }
20
        return preg_replace('/\=\d+/', '', $url);
21
    }
22
23
    /**
24
     * Returns an new ObjectId-like string, where its first 8
25
     * characters encode the current unix timestamp and the
26
     * next 16 are random.
27
     *
28
     * @see http://php.net/manual/en/mongodb-bson-objectid.construct.php
29
     *
30
     * @return string
31
     */
32
    public static function generateId()
33
    {
34
        return dechex(time()) . bin2hex(random_bytes(8));
35
    }
36
37
}
38