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

CheckUploadStatus   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A handle() 0 4 1
1
<?php
2
3
namespace STS\StorageConnect\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Foundation\Bus\Dispatchable;
8
use Illuminate\Queue\InteractsWithQueue;
9
use Illuminate\Queue\SerializesModels;
10
use STS\Backoff\Backoff;
11
use STS\Backoff\Strategies\PolynomialStrategy;
12
use STS\StorageConnect\Models\CloudStorage;
13
use STS\StorageConnect\UploadResponse;
14
15
class CheckUploadStatus implements ShouldQueue
16
{
17
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
18
19
    /**
20
     * @var CloudStorage
21
     */
22
    protected $storage;
23
24
    /**
25
     * @var UploadResponse
26
     */
27
    protected $response;
28
29
    /**
30
     * CheckUploadStatus constructor.
31
     *
32
     * @param CloudStorage   $storage
33
     * @param UploadResponse $response
34
     */
35
    public function __construct( CloudStorage $storage, UploadResponse $response )
36
    {
37
        $this->storage = $storage;
38
        $this->response = $response;
39
        $this->delay = (new Backoff)
40
            ->setStrategy(new PolynomialStrategy(5, 3))
41
            ->setWaitCap(900)
42
            ->getWaitTime($response->getStatusChecks());
43
    }
44
45
    /**
46
     *
47
     */
48
    public function handle()
49
    {
50
        $this->storage->checkUploadStatus($this->response);
51
    }
52
}