Slugify   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
c 0
b 0
f 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A slugify() 0 7 1
1
<?php
2
3
namespace KW\Inlagg;
4
5
/**
6
 * Slygifies titles
7
 *
8
 */
9
class Slugify
10
{
11
    /**
12
    * Create a slug of a string, to be used as url.
13
    *
14
    * @param string $str the string to format as slug.
15
    *
16
    * @return str the formatted slug.
17
    */
18
    public function slugify($str)
19
    {
20
        $str = mb_strtolower(trim($str));
21
        $str = str_replace(array('å','ä','ö'), array('a','a','o'), $str);
22
        $str = preg_replace('/[^a-z0-9-]/', '-', $str);
23
        $str = trim(preg_replace('/-+/', '-', $str), '-');
24
        return $str;
25
    }
26
}
27