SluggableHelper   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
dl 0
loc 17
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSlug() 0 8 1
1
<?php declare(strict_types = 1);
2
3
namespace Suilven\Sluggable\Helper;
4
5
use SilverStripe\View\Parsers\URLSegmentFilter;
6
7
class SluggableHelper
8
{
9
    /**
10
     * Convert the configured field and it's associated value into a slug
11
     * e.g. Liverpool Football Club => liverpool-football-club
12
     *
13
     * @param string $fieldValue The value of the field
14
     * @return string field value sluggified
15
     */
16
    public function getSlug(string $fieldValue): string
17
    {
18
19
        // use the standard SilverStripe tool for slugging URLs.  This optionally may have a different transliterator
20
        // associated with it
21
        $slugger = new URLSegmentFilter();
22
23
        return $slugger->filter($fieldValue);
24
    }
25
}
26