Skip to content

Commit f3d57d7

Browse files
committed
Fix PHPDoc + PSR2
1 parent b5f1cf5 commit f3d57d7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/iterable-functions.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
/**
66
* Check wether or not a variable is iterable (i.e array or \Traversable)
7-
* @param array|\Traversable $iterable
7+
*
8+
* @param array|\Traversable $iterable
89
* @return bool
910
*/
1011
function is_iterable($iterable)
@@ -17,7 +18,8 @@ function is_iterable($iterable)
1718

1819
/**
1920
* Copy the iterable into an array. If the iterable is already an array, return it.
20-
* @param array|\Traversable $iterable
21+
*
22+
* @param array|\Traversable $iterable
2123
* @return array
2224
*/
2325
function iterable_to_array($iterable)
@@ -27,16 +29,21 @@ function iterable_to_array($iterable)
2729
}
2830

2931
if (!function_exists('iterable_to_traversable')) {
32+
33+
/**
34+
* If the iterable is not intance of \Traversable, it is an array => convert it to an ArrayIterator.
35+
*
36+
* @param $iterable
37+
* @return \Traversable
38+
*/
3039
function iterable_to_traversable($iterable)
3140
{
3241
if ($iterable instanceof Traversable) {
3342
return $iterable;
34-
}
35-
elseif (is_array($iterable)) {
43+
} elseif (is_array($iterable)) {
3644
return new ArrayIterator($iterable);
37-
}
38-
else {
45+
} else {
3946
throw new \InvalidArgumentException(sprintf('Expected array or \\Traversable, got %s', is_object($iterable) ? get_class($iterable) : gettype($iterable)));
4047
}
4148
}
42-
}
49+
}

0 commit comments

Comments
 (0)