Passed
Push — Showing-Posts ( a9b412...91b09f )
by Stone
01:58
created

PostVerification::isSlugUnique()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
namespace App\Controllers\Ajax;
3
4
use App\Models\SlugModel;
5
use Core\AjaxController;
6
class PostVerification extends AjaxController{
7
8
    /**
9
     * checks if the slug is unique
10
     * @return bool is unique
11
     * @throws \Core\JsonException
12
     * @throws \ErrorException
13
     */
14
    public function isSlugUnique()
15
    {
16
        $this->onlyAdmin();
17
        if (!$this->container->getRequest()->isPost()) {
18
            throw new JsonException('Call is not post');
0 ignored issues
show
Bug introduced by
The type App\Controllers\Ajax\JsonException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
        }
20
21
        $postSlug = $this->request->getData("postSlug");
22
23
        $slugModel = new SlugModel($this->container);
24
        $data = $slugModel->isUnique($postSlug, "posts", "posts_slug");
25
        echo json_encode($data);
26
    }
27
28
29
}