Passed
Push — master ( f70266...e410c8 )
by Shahrad
01:49
created

UploadResult::addFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace EasyHttp\Model;
4
5
use EasyHttp\Util\Utils;
6
7
/**
8
 * Class UploadResult
9
 *
10
 * @link    https://github.com/shahradelahi/easy-http
11
 * @author  Shahrad Elahi (https://github.com/shahradelahi)
12
 * @license https://github.com/shahradelahi/easy-http/blob/master/LICENSE (MIT License)
13
 */
14
class UploadResult
15
{
16
17
    /**
18
     * The unique identifier of the uploaded files.
19
     *
20
     * @var string
21
     */
22
    public string $id;
23
24
    /**
25
     * Start time of the upload in microseconds
26
     *
27
     * @var float
28
     */
29
    public float $startTime;
30
31
    /**
32
     * End time of the upload in microseconds
33
     *
34
     * @var float
35
     */
36
    public float $endTime;
37
38
    /**
39
     * The upload status
40
     *
41
     * @var bool
42
     */
43
    public bool $success = false;
44
45
    /**
46
     * The uploaded files
47
     *
48
     * @var array [{id, location, elapsedTime, status}, ...]
49
     */
50
    public array $uploads = [];
51
52
    /**
53
     * HttpResponse
54
     *
55
     * @var HttpResponse
56
     */
57
    public HttpResponse $response;
58
59
    /**
60
     * The Constructor of the UploadResult class
61
     */
62
    public function __construct()
63
    {
64
        $this->id = Utils::randomString(16);
65
    }
66
67
    /**
68
     * Add a file to the upload result
69
     *
70
     * @param string $location
71
     * @param float $elapsedTime
72
     * @param string $status
73
     *
74
     * @return void
75
     */
76
    public function addFile(string $location, float $elapsedTime, string $status): void
77
    {
78
        $this->uploads[] = [
79
            'id' => Utils::randomString(16),
80
            'location' => $location,
81
            'elapsedTime' => $elapsedTime,
82
            'status' => $status
83
        ];
84
    }
85
86
}