Passed
Pull Request — master (#57)
by Stone
03:27
created

AjaxSlugify   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A slugifyString() 0 10 1
1
<?php
2
3
namespace App\Controllers\Ajax;
4
5
use Core\AjaxController;
6
use Cocur\Slugify\Slugify;
7
use Core\JsonException;
8
use Core\Traits\StringFunctions;
9
10
class AjaxSlugify extends AjaxController
11
{
12
    use StringFunctions;
0 ignored issues
show
Bug introduced by
The trait Core\Traits\StringFunctions requires the property $childNodes which is not provided by App\Controllers\Ajax\AjaxSlugify.
Loading history...
13
14
    /**
15
     * @return string slugified string
16
     * @throws JsonException
17
     */
18
    public function slugifyString()
19
    {
20
        //only admins can update the slug
21
        $this->onlyAdmin();
22
        $this->onlyPost();
23
        $slug = $this->request->getData("slugText-update");
24
        $result = array();
25
        $slugify = new Slugify();
26
        $result['slug'] = $slugify->slugify($slug);
27
        echo json_encode($result);
28
    }
29
}