Completed
Push — master ( 461219...630231 )
by Harry
04:03
created

TraversableTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getArray() 0 7 4
1
<?php
2
3
namespace Graze\DataFile\Format\Formatter;
4
5
use InvalidArgumentException;
6
use Traversable;
7
8
trait TraversableTrait
9
{
10
    /**
11
     * @param array|Traversable $row
12
     *
13
     * @return array
14
     */
15 21
    protected function getArray($row)
16
    {
17 21
        if (!$row instanceof Traversable && !is_array($row)) {
18 2
            throw new InvalidArgumentException("The input is not an array or traversable");
19
        }
20 19
        return ($row instanceof Traversable) ? iterator_to_array($row, true) : $row;
21
    }
22
}
23