Passed
Push — 8.0 ( ada0a8...7d1def )
by liu
11:09
created

ValidateException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 25
ccs 0
cts 5
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 3 1
A getError() 0 3 1
A __construct() 0 3 2
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006-2021 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: yunwuxin <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think\exception;
14
15
/**
16
 * 数据验证异常
17
 */
18
class ValidateException extends \RuntimeException
19
{
20
    public function __construct(protected $error, protected $key = '')
21
    {
22
        $this->message = is_array($error) ? json_encode($error) : $error;
23
    }
24
25
    /**
26
     * 获取验证错误信息
27
     * @access public
28
     * @return array|string
29
     */
30
    public function getError()
31
    {
32
        return $this->error;
33
    }
34
35
    /**
36
     * 获取验证错误字段
37
     * @access public
38
     * @return string
39
     */
40
    public function getKey()
41
    {
42
        return $this->key;
43
    }
44
45
}
46