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

AjaxSlugify::slugifyString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 10
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
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
}