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

CryptoExchangesCollectionBuilder   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\CryptoExchangesCollection;
8
use Sarnado\Converter\Contracts\CollectionBuilderInterface;
9
use Sarnado\Converter\Objects\CryptoExchangeObject;
10
use Tightenco\Collect\Support\Collection;
11
12
/**
13
 * Class CryptoExchangesCollectionBuilder
14
 * @package Sarnado\Converter\Builders
15
 */
16
class CryptoExchangesCollectionBuilder implements CollectionBuilderInterface
17
{
18
19 9
    public static function build(array $data): CryptoExchangesCollection
20
    {
21 9
        $result = [];
22 9
        if (!empty($data))
23
        {
24 9
            foreach ($data as $item)
25
            {
26 9
                if (!is_string($item))
27
                {
28 3
                    throw new \UnexpectedValueException('Not valid item');
29
                }
30 6
                $result[] = new CryptoExchangeObject($item);
31
            }
32
        }
33 6
        return new CryptoExchangesCollection($result);
34
    }
35
}
36