Exception::setData()   A
last analyzed

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
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: 麦当苗儿 <[email protected]> <http://zjzit.cn>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think;
14
15
/**
16
 * 异常基础类
17
 * @package think
18
 */
19
class Exception extends \Exception
20
{
21
    /**
22
     * 保存异常页面显示的额外Debug数据
23
     * @var array
24
     */
25
    protected $data = [];
26
27
    /**
28
     * 设置异常额外的Debug数据
29
     * 数据将会显示为下面的格式
30
     *
31
     * Exception Data
32
     * --------------------------------------------------
33
     * Label 1
34
     *   key1      value1
35
     *   key2      value2
36
     * Label 2
37
     *   key1      value1
38
     *   key2      value2
39
     *
40
     * @access protected
41
     * @param  string $label 数据分类,用于异常页面显示
42
     * @param  array  $data  需要显示的数据,必须为关联数组
43
     */
44
    final protected function setData(string $label, array $data)
45
    {
46
        $this->data[$label] = $data;
47
    }
48
49
    /**
50
     * 获取异常额外Debug数据
51
     * 主要用于输出到异常页面便于调试
52
     * @access public
53
     * @return array 由setData设置的Debug数据
54
     */
55
    final public function getData()
56
    {
57
        return $this->data;
58
    }
59
60
}
61