Test Failed
Pull Request — master (#160)
by Maximo
07:00
created

Validation::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 2
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas;
6
7
use Phalcon\Validation as PhalconValidation;
8
use Canvas\Exception\UnprocessableRequestException;
9
10
/**
11
 * Class Validation.
12
 *
13
 * @package Canvas
14
 */
15
class Validation extends PhalconValidation
16
{
17
    /**
18
     *
19
     * Overwrite to throw the exception and avoid all the overloaded code
20
     * Validate a set of data according to a set of rules.
21
     *
22
     * @param array|object data
0 ignored issues
show
Bug introduced by
The type Canvas\data was not found. Did you mean data? If so, make sure to prefix the type with \.
Loading history...
23
     * @param object entity
0 ignored issues
show
Bug introduced by
The type Canvas\entity 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...
24
     * @return \Phalcon\Validation\Message\Group
0 ignored issues
show
Bug introduced by
The type Phalcon\Validation\Message\Group 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...
25
     */
26
    public function validate($data = null, $entity = null)
27
    {
28
        $validate = parent::validate($data, $entity);
29
30
        if (count($validate)) {
31
            throw new UnprocessableRequestException($validate[0]->getMessage());
32
        }
33
34
        return $validate;
35
    }
36
}
37