Currency::fromResponse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace GloBee\PaymentApi\Models;
4
5
class Currency extends Model
6
{
7
8
    protected $id;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
9
    protected $name;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
10
11 2
    public function __construct($id, $name)
0 ignored issues
show
Coding Style Documentation introduced by
Missing function doc comment
Loading history...
12
    {
13 2
        $this->id = $id;
14 2
        $this->name = $name;
15 2
    }
16
17
    /**
18
     * @param array $data
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
19
     *
20
     * @return Currency[]
21
     */
22 2
    public static function fromResponse(array $data)
23
    {
24 2
        $currencies = [];
25
26 2
        foreach ($data as $currency) {
27 2
            $self = new self($currency['id'], $currency['name']);
28
29 2
            $currencies[] = $self;
30
        }
31
32 2
        return $currencies;
33
    }
34
}
35