Passed
Push — Showing-Posts ( 7973b5...d5badc )
by Stone
02:03
created

AjaxSlugify::slugifyString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controllers\Ajax;
4
5
use Core\AjaxController;
6
use Cocur\Slugify\Slugify;
7
8
class AjaxSlugify extends AjaxController
9
{
10
    /**
11
     * @param string $string the string to slugify
12
     * @return string slugified string
13
     * @throws \Exception Cocur\Slugify\Slugify error
14
     */
15
    public function slugifyString()
16
    {
17
        $string = $this->request->getData("slugText-update");
18
        $result = array();
19
        $slugify = new Slugify();
20
        $result['slug'] = $slugify->slugify($string);
21
        echo json_encode($result);
22
    }
23
}