Completed
Push — graph-cache ( 447735 )
by Tony
10:09
created

Functions.php ➔ safename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @param $name
5
 * @return mixed
6
 */
7
function safename($name)
8
{
9
    return preg_replace('/[^\w\d,._\-]/', '_', $name);
10
}
11
12
/**
13
 * @param $string
14
 * @return mixed
15
 */
16
function shorten_interface_type($string)
17
{
18
    return str_ireplace(
19
        array(
20
            'FastEthernet',
21
            'TenGigabitEthernet',
22
            'GigabitEthernet',
23
            'Port-Channel',
24
            'Ethernet',
25
        ),
26
        array(
27
            'Fa',
28
            'Te',
29
            'Gi',
30
            'Po',
31
            'Eth',
32
        ),
33
        $string
34
    );
35
}//end shorten_interface_type()
36