Completed
Push — master ( d5f261...ed671f )
by Joseph
01:44
created

UploadException   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 96
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A retry() 0 7 1
A disable() 0 5 1
A getRequest() 0 4 1
A setStorage() 0 4 1
A shouldRetry() 0 4 1
A shouldDisable() 0 4 1
A getReason() 0 4 1
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 retry( $message )
52
    {
53
        $this->retry = true;
54
        $this->message = $message;
55
56
        return $this;
57
    }
58
59
    /**
60
     * @param $message
61
     * @param null $reason
62
     */
63
    public function disable( $message, $reason = null)
64
    {
65
        $this->message = $message;
66
        $this->reason = $reason;
67
    }
68
69
    /**
70
     * @return UploadRequest
71
     */
72
    public function getRequest()
73
    {
74
        return $this->request;
75
    }
76
77
    /**
78
     * @param CloudStorage $storage
79
     */
80
    public function setStorage(CloudStorage $storage)
81
    {
82
        $this->storage = $storage;
83
    }
84
85
    /**
86
     * @return bool
87
     */
88
    public function shouldRetry()
89
    {
90
        return $this->retry;
91
    }
92
93
    /**
94
     * @return bool
95
     */
96
    public function shouldDisable()
97
    {
98
        return $this->disable;
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    public function getReason()
105
    {
106
        return $this->reason;
107
    }
108
}