Completed
Pull Request — master (#9)
by Bernhard
02:13
created

Currency::fromResponse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
namespace GloBee\PaymentApi\Models;
4
5
class Currency extends Model
6
{
7
8
    protected $readonlyProperties = [
9
        'id' => null,
10
        'name' => null,
11
    ];
12
13
    /**
14
     * @param array $data
15
     *
16
     * @return Currency[]
17
     */
18 2
    public static function fromResponse(array $data)
19
    {
20 2
        $currencies = [];
21
22 2
        foreach ($data as $currency) {
23 2
            $self = new self();
24 2
            $self->properties['id'] = $currency['id'];
25 2
            $self->properties['name'] = $currency['name'];
26
27 2
            $currencies[] = $self;
28
        }
29
30 2
        return $currencies;
31
    }
32
}
33