Completed
Push — master ( 43a76d...75ce5f )
by David
01:41
created

GetBulkJobsResponse::create()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\EmailValidationV4;
13
14
use Mailgun\Model\ApiResponse;
15
use Mailgun\Model\PaginationResponse;
16
17
final class GetBulkJobsResponse implements ApiResponse
18
{
19
    use PaginationResponse;
20
21
    /**
22
     * @var int
23
     */
24
    private $total = 0;
25
26
    /**
27
     * @var array
28
     */
29
    private $jobs = [];
30
31 1
    private function __construct()
32
    {
33 1
    }
34
35 1
    public static function create(array $data): self
36
    {
37 1
        $model = new self();
38
39 1
        $jobs = [];
40
41 1
        if (isset($data['jobs'])) {
42 1
            foreach ($data['jobs'] as $job) {
43 1
                $jobs[] = Job::create($job);
44
            }
45
        }
46
47 1
        $model->jobs = $jobs;
48 1
        $model->total = $data['total'] ?? 0;
49 1
        $model->paging = $data['paging'];
50
51 1
        return $model;
52
    }
53
54
    public function getTotal(): int
55
    {
56
        return $this->total;
57
    }
58
59 1
    public function getJobs(): array
60
    {
61 1
        return $this->jobs;
62
    }
63
}
64