Completed
Push — master ( a77222...354732 )
by Joseph
01:48
created

UploadException::getReason()   A

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 STS\StorageConnect\Exceptions;
4
5
use STS\StorageConnect\Models\CloudStorage;
6
use STS\StorageConnect\UploadRequest;
7
use Throwable;
8
9
/**
10
 * Class UploadException
11
 * @package STS\StorageConnect\Exceptions
12
 */
13
class UploadException extends \RuntimeException
14
{
15
    /**
16
     * @var bool
17
     */
18
    protected $retry = false;
19
20
    /**
21
     * @var bool
22
     */
23
    protected $disable = false;
24
25
    /**
26
     * @var string
27
     */
28
    protected $reason;
29
30
    /**
31
     * @var CloudStorage
32
     */
33
    protected $storage;
34
35
    /**
36
     * @var UploadRequest
37
     */
38
    protected $request;
39
40
    public function __construct(UploadRequest $request, $previous = null)
41
    {
42
        $this->request = $request;
43
        parent::__construct(null, null, $previous);
44
    }
45
46
    /**
47
     * @param $message
48
     *
49
     * @return $this
50
     */
51
    public function message ( $message )
52
    {
53
        $this->message = $message;
54
55
        return $this;
56
    }
57
58
    /**
59
     * @param $message
60
     *
61
     * @return $this
62
     */
63
    public function retry( $message )
64
    {
65
        $this->retry = true;
66
        $this->message = $message;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @param $message
73
     * @param null $reason
74
     */
75
    public function disable( $message, $reason = null)
76
    {
77
        $this->message = $message;
78
        $this->reason = $reason;
79
    }
80
81
    /**
82
     * @return UploadRequest
83
     */
84
    public function getRequest()
85
    {
86
        return $this->request;
87
    }
88
89
    /**
90
     * @param CloudStorage $storage
91
     */
92
    public function setStorage(CloudStorage $storage)
93
    {
94
        $this->storage = $storage;
95
    }
96
97
    /**
98
     * @return bool
99
     */
100
    public function shouldRetry()
101
    {
102
        return $this->retry;
103
    }
104
105
    /**
106
     * @return bool
107
     */
108
    public function shouldDisable()
109
    {
110
        return $this->disable;
111
    }
112
113
    /**
114
     * @return string
115
     */
116
    public function getReason()
117
    {
118
        return $this->reason;
119
    }
120
}