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

CheckUploadStatus::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
nc 1
cc 1
nop 2
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
}