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

MultiCollection::isConsistentDataStructure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 MultiCollection extends AbstractCollection
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function contains($value, $index = null)
24
    {
25
        if (parent::contains($value, $index)) {
26
            return true;
27
        }
28
        foreach ($this->data as $key => $arr) {
29
            if (is_traversable($arr)) {
30
                $coll = static::factory($arr);
31
                if ($coll->contains($value, $index)) {
32
                    return true;
33
                }
34
            }
35
        }
36
        
37
        return false;
38
    }
39
40
    protected function isConsistentDataStructure($data)
41
    {
42
        return static::isMultiDimensional($data);
43
    }
44
}
45