Failed Conditions
Pull Request — master (#321)
by Anton
23:35 queued 08:33
created

modules/system/controllers/rest/delete.php (7 issues)

Labels
Severity
1
<?php
2
/**
3
 * REST controller for DELETE method
4
 *
5
 * @category Application
6
 *
7
 * @author   Anton Shevchuk
8
 * @created  19.02.15 16:27
9
 */
10
11
namespace Application;
12
13
use Bluz\Crud\Table;
0 ignored issues
show
The type Bluz\Crud\Table 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...
14
use Bluz\Db\Exception\TableNotFoundException;
0 ignored issues
show
The type Bluz\Db\Exception\TableNotFoundException 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...
15
use Bluz\Http\Exception\BadRequestException;
0 ignored issues
show
The type Bluz\Http\Exception\BadRequestException 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...
16
use Bluz\Http\Exception\NotFoundException;
0 ignored issues
show
The type Bluz\Http\Exception\NotFoundException 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...
17
use Bluz\Http\Exception\NotImplementedException;
0 ignored issues
show
The type Bluz\Http\Exception\NotImplementedException 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...
18
use Bluz\Http\StatusCode;
0 ignored issues
show
The type Bluz\Http\StatusCode 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
use Bluz\Proxy\Response;
0 ignored issues
show
The type Bluz\Proxy\Response 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...
20
21
/**
22
 * @accept HTML
23
 * @accept JSON
24
 * @method DELETE
25
 *
26
 * @param Table $crud
27
 * @param mixed $primary
28
 * @param array $data
29
 *
30
 * @return void
31
 * @throws BadRequestException
32
 * @throws NotFoundException
33
 * @throws NotImplementedException
34
 * @throws TableNotFoundException
35
 */
36
return function (Table $crud, $primary, $data) {
37
    if (!empty($primary)) {
38
        // delete one
39
        // @throws NotFoundException
40
        $crud->deleteOne($primary);
41
    } else {
42
        // delete collection
43
        // @throws NotFoundException
44
        if (!count($data)) {
45
            // data not exist
46
            throw new BadRequestException;
47
        }
48 1
        $crud->deleteSet($data);
49
    }
50
    Response::setStatusCode(StatusCode::NO_CONTENT);
51
};
52