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

CryptoCurrenciesCollectionBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 15 4
1
<?php
2
3
4
namespace Sarnado\Converter\Builders;
5
6
7
use Sarnado\Converter\Collections\CryptoCurrenciesCollection;
8
use Sarnado\Converter\Contracts\CollectionBuilderInterface;
9
use Sarnado\Converter\Objects\CryptoCurrencyObject;
10
11
class CryptoCurrenciesCollectionBuilder implements CollectionBuilderInterface
12
{
13
14 9
    public static function build(array $data): CryptoCurrenciesCollection
15
    {
16 9
        $result = [];
17 9
        if (!empty($data))
18
        {
19 9
            foreach ($data as $item)
20
            {
21 9
                if (!is_string($item))
22
                {
23 3
                    throw new \UnexpectedValueException('Not valid item');
24
                }
25 6
                $result[] = new CryptoCurrencyObject($item);
26
            }
27
        }
28 6
        return new CryptoCurrenciesCollection($result);
29
    }
30
}
31