b2pweb /
bdf-collections
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Bdf\Collection\Stream; |
||
| 4 | |||
| 5 | use Traversable; |
||
| 6 | use function is_array; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Utility class for handle streams |
||
| 10 | */ |
||
| 11 | final class Streams |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Wrap a value into a stream |
||
| 15 | * The best stream implementation is used according to the value type : |
||
| 16 | * |
||
| 17 | * - If the value is a Streamable object, return the related stream |
||
| 18 | * - If the value is null or an empty array, return an EmptyStream |
||
| 19 | * - If the value is an array, return an ArrayStream |
||
| 20 | * - If the value is Traversable, return an IteratorStream |
||
| 21 | * - In other cases, return a SingletonStream |
||
| 22 | * |
||
| 23 | * @template V |
||
| 24 | * |
||
| 25 | * @param V|V[]|Traversable<mixed, V> $value The value to wrap |
||
|
0 ignored issues
–
show
|
|||
| 26 | * |
||
| 27 | * @return StreamInterface<V, mixed> |
||
| 28 | */ |
||
| 29 | 37 | public static function wrap($value): StreamInterface |
|
| 30 | { |
||
| 31 | 37 | if ($value instanceof StreamInterface) { |
|
| 32 | 1 | return $value; |
|
| 33 | } |
||
| 34 | |||
| 35 | 37 | if ($value instanceof Streamable) { |
|
| 36 | 1 | return $value->stream(); |
|
| 37 | } |
||
| 38 | |||
| 39 | 37 | if ($value === null || $value === []) { |
|
| 40 | 2 | return EmptyStream::instance(); |
|
| 41 | } |
||
| 42 | |||
| 43 | 37 | if (is_array($value)) { |
|
| 44 | 37 | return new ArrayStream($value); |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | if ($value instanceof Traversable) { |
|
|
0 ignored issues
–
show
|
|||
| 48 | 1 | return new IteratorStream($value); |
|
| 49 | } |
||
| 50 | |||
| 51 | 3 | return new SingletonStream($value); |
|
| 52 | } |
||
| 53 | } |
||
| 54 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths