Completed
Pull Request — master (#175)
by Luke
06:22 queued 01:51
created

Collection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isConsistentDataStructure() 0 14 4
1
<?php
2
3
/*
4
 * CSVelte: Slender, elegant CSV for PHP
5
 * Inspired by Python's CSV module and Frictionless Data and the W3C's CSV
6
 * standardization efforts, CSVelte was written in an effort to take all the
7
 * suck out of working with CSV.
8
 *
9
 * @version   {version}
10
 * @copyright Copyright (c) 2016 Luke Visinoni <[email protected]>
11
 * @author    Luke Visinoni <[email protected]>
12
 * @license   https://github.com/deni-zen/csvelte/blob/master/LICENSE The MIT License (MIT)
13
 */
14
namespace CSVelte\Collection;
15
16
use function CSVelte\is_traversable;
17
18
class Collection extends AbstractCollection
19
{
20
    /**
21
     * Is correct input data type?
22
     *
23
     * @param mixed $data The data to assert correct type of
24
     *
25
     * @return bool
26
     */
27
    protected function isConsistentDataStructure($data)
28
    {
29
        // this collection may only contain scalar or null values
30
        if (!is_traversable($data)) {
31
            return false;
32
        }
33
        foreach ($data as $key => $val) {
34
            if (is_traversable($val)) {
35
                return false;
36
            }
37
        }
38
39
        return true;
40
    }
41
}
42