Completed
Push — refactoring ( 4b6f46...3130f4 )
by Issei
07:36
created

Assert::isIterable()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 3
eloc 3
nc 2
nop 2
1
<?php
2
3
namespace Issei\StreamedCsvResponse;
4
5
/**
6
 * Assertion.
7
 *
8
 * {@internal Don't use this in user-land code }}
9
 *
10
 * @author Issei Murasawa <[email protected]>
11
 */
12
final class Assert
13
{
14
    /**
15
     * Throws an \InvalidArgumentException if given value is not iterable.
16
     *
17
     * @param mixed  $value
18
     * @param string $message
19
     *
20
     * @return bool
21
     */
22
    public static function isIterable($value, $message)
23
    {
24
        if (!$value instanceof \Traversable && !is_array($value)) {
25
            throw new \InvalidArgumentException($message);
26
        }
27
    }
28
29
    private function __construct() {}
30
}
31