Completed
Push — master ( 3fbd33...51cff9 )
by David
02:08
created

CredentialResponse::getCredentials()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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\Domain;
13
14
use Mailgun\Model\ApiResponse;
15
16
/**
17
 * @author Sean Johnson <[email protected]>
18
 */
19 View Code Duplication
final class CredentialResponse implements ApiResponse
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    private $totalCount;
22
    private $items;
23
24 1
    public static function create(array $data): self
25
    {
26 1
        $items = [];
27 1
        if (isset($data['items'])) {
28 1
            foreach ($data['items'] as $item) {
29 1
                $items[] = CredentialResponseItem::create($item);
30
            }
31
        }
32
33 1
        if (isset($data['total_count'])) {
34 1
            $count = (int) $data['total_count'];
35
        } else {
36
            $count = count($items);
37
        }
38
39 1
        $model = new self();
40 1
        $model->totalCount = $count;
41 1
        $model->items = $items;
42
43 1
        return $model;
44
    }
45
46 1
    private function __construct()
47
    {
48 1
    }
49
50 1
    public function getTotalCount(): int
51
    {
52 1
        return $this->totalCount;
53
    }
54
55
    /**
56
     * @return CredentialResponseItem[]
57
     */
58 1
    public function getCredentials(): array
59
    {
60 1
        return $this->items;
61
    }
62
}
63