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

ValidateException::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 1
b 0
f 0
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