Completed
Pull Request — master (#170)
by Luke
02:40
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
 * CSVelte: Slender, elegant CSV for PHP
4
 *
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   v${CSVELTE_DEV_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
    protected function isConsistentDataStructure($data)
21
    {
22
        return static::isMultiDimensional($data);
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function contains($value, $index = null)
29
    {
30
        if (parent::contains($value, $index)) {
31
            return true;
32
        } else {
33
            foreach ($this->data as $key => $arr) {
34
                if (is_traversable($arr)) {
35
                    $coll = static::factory($arr);
36
                    if ($coll->contains($value, $index)) {
37
                        return true;
38
                    }
39
                }
40
            }
41
        }
42
        return false;
43
    }
44
}