Passed
Push — master ( 8884a6...674cbd )
by sarnado
02:38
created

CryptoRateObjectBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
4
namespace Sarnado\Converter\Builders;
5
6
7
use Sarnado\Converter\Contracts\BuilderInterface;
8
use Sarnado\Converter\Objects\CryptoRateObject;
9
10
/**
11
 * Class CryptoRateObjectBuilder
12
 * @package Sarnado\Converter\Builders
13
 */
14
class CryptoRateObjectBuilder implements BuilderInterface
15
{
16
17
    /**
18
     * @param $data
19
     * @return CryptoRateObject
20
     */
21 15
    public static function build($data): CryptoRateObject
22
    {
23 15
        if (!isset($data['rate'], $data['exchange'], $data['fiat'], $data['crypto'], $data['time']))
24
        {
25 3
            throw new \UnexpectedValueException('Not valid item');
26
        }
27 12
        return new CryptoRateObject($data['crypto'], $data['fiat'], $data['rate'], $data['time'], $data['exchange']);
28
    }
29
}
30