PendingError::getHeader()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Imanghafoori\LaravelMicroscope\ErrorReporters;
4
5
class PendingError
6
{
7
    public static $maxLength = 60;
8
9
    private $type;
10
11
    private $header;
12
13
    private $errorData;
14
15
    private $linkPath;
16
17
    private $linkLineNumber = 4;
18
19
    /**
20
     * PendingError constructor.
21
     *
22
     * @param $type
23
     */
24
    public function __construct($type)
25
    {
26
        $this->type = $type;
27
    }
28
29
    /**
30
     * Sets the content of the error header.
31
     *
32
     * @param  string  $header
33
     *
34
     * @return $this
35
     */
36
    public function header(string $header)
37
    {
38
        $this->header = $header;
39
40
        return $this;
41
    }
42
43
    /**
44
     * Sets the data to give out as error.
45
     *
46
     * @param $data
47
     *
48
     * @return $this
49
     */
50
    public function errorData($data)
51
    {
52
        $this->setMaxLength(strlen($data));
53
        $this->errorData = $data;
54
55
        return $this;
56
    }
57
58
    /**
59
     * Sets the link to the source error.
60
     *
61
     * @param $path
62
     * @param  int  $lineNumber
63
     *
64
     * @return $this
65
     */
66
    public function link($path = null, $lineNumber = 4)
67
    {
68
        $this->setMaxLength(strlen($path) - 13);
69
        $this->linkPath = $path;
70
        $this->linkLineNumber = $lineNumber;
71
72
        return $this;
73
    }
74
75
    public function getType()
76
    {
77
        return $this->type;
78
    }
79
80
    public function getHeader()
81
    {
82
        return $this->header;
83
    }
84
85
    public function getErrorData()
86
    {
87
        return $this->errorData;
88
    }
89
90
    public function getLinkPath()
91
    {
92
        return $this->linkPath;
93
    }
94
95
    public function getLinkLineNumber()
96
    {
97
        return $this->linkLineNumber;
98
    }
99
100
    private function setMaxLength($len)
101
    {
102
        (self::$maxLength < $len) && self::$maxLength = $len;
103
        self::$maxLength > 100 && self::$maxLength = 100;
104
    }
105
}
106