SVChecker   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A checking() 0 9 4
1
<?php
2
/**
3
 * Sourcing value checker
4
 * User: moyo
5
 * Date: 2018/6/8
6
 * Time: 3:06 PM
7
 */
8
9
namespace Carno\Validator\Chips;
10
11
use Carno\Validator\Valid\Message;
12
use Carno\Validator\Valid\Rule;
13
use Respect\Validation\Exceptions\ValidationException;
14
use Throwable;
15
16
trait SVChecker
17
{
18
    /**
19
     * @param Rule $rule
20
     * @param mixed $input
21
     * @throws Throwable
22
     */
23
    protected function checking(Rule $rule, $input)
24
    {
25
        if ($rule->e()->valid()) {
26
            $rule->v()->validate($input) || $rule->e()->throws();
27
        } else {
28
            try {
29
                $rule->v()->check($input);
30
            } catch (ValidationException $e) {
31
                (new Message($e->setName($rule->f())->getMainMessage()))->throws();
32
            }
33
        }
34
    }
35
}
36