Passed
Pull Request — dev (#832)
by Tristan
19:00 queued 13:53
created

BaseDataValidator::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Services\Validation;
4
5
use App\Services\Validation\Contracts\DataValidator;
6
7
abstract class BaseDataValidator implements DataValidator
8
{
9
    /**
10
     * Runs the validator, redirecting back, with errors, if validation fails.
11
     *
12
     * @param mixed[] $data The data to validate.
13
     * @return void
14
     */
15 2
    public function validate(array $data): void
16
    {
17 2
        $this->validator($data)->validate();
18 2
    }
19
20
    /**
21
     * Returns true if the validator passes
22
     *
23
     * @param mixed[] $data Data to validate.
24
     * @return boolean
25
     */
26 9
    public function isValid(array $data) : bool
27
    {
28 9
        return $this->validator($data)->passes();
29
    }
30
}
31