Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrojny committed Jan 14, 2014
1 parent 6b5fdb9 commit 901e167
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,3 +29,4 @@ functional.la
.libs/
functional.lo
/phpunit.xml
/vendor
6 changes: 2 additions & 4 deletions src/Functional/InvokeFirst.php
Expand Up @@ -36,9 +36,7 @@ function invoke_first($collection, $methodName, array $arguments = array())
Exceptions\InvalidArgumentException::assertCollection($collection, __FUNCTION__, 1);
Exceptions\InvalidArgumentException::assertMethodName($methodName, __FUNCTION__, 2);

foreach ($collection as $index => $element) {

$value = null;
foreach ($collection as $element) {

$callback = array($element, $methodName);
if (is_callable($callback)) {
Expand All @@ -47,4 +45,4 @@ function invoke_first($collection, $methodName, array $arguments = array())
}

return null;
}
}
8 changes: 3 additions & 5 deletions src/Functional/InvokeLast.php
Expand Up @@ -38,9 +38,7 @@ function invoke_last($collection, $methodName, array $arguments = array())

$lastCallback = null;

foreach ($collection as $index => $element) {

$value = null;
foreach ($collection as $element) {

$callback = array($element, $methodName);
if (is_callable($callback)) {
Expand All @@ -51,6 +49,6 @@ function invoke_last($collection, $methodName, array $arguments = array())
if (!$lastCallback) {
return null;
}

return call_user_func_array($lastCallback, $arguments);
}
}
6 changes: 3 additions & 3 deletions src/Functional/Product.php
Expand Up @@ -22,13 +22,13 @@
*/
namespace Functional;

use RecursiveIteratorIterator;
use RecursiveArrayIterator;
use Traversable;

/**
* Takes a collection and returns the product of all elements
*
* @param \Traversable|array $collection
* @param Traversable|array $collection
* @param int $initial
* @return integer|float
*/
function product($collection, $initial = 1)
Expand Down
6 changes: 3 additions & 3 deletions src/Functional/Ratio.php
Expand Up @@ -22,13 +22,13 @@
*/
namespace Functional;

use RecursiveIteratorIterator;
use RecursiveArrayIterator;
use Traversable;

/**
* Takes a collection and returns the quotient of all elements
*
* @param \Traversable|array $collection
* @param Traversable|array $collection
* @param int $initial
* @return integer|float
*/
function ratio($collection, $initial = 1)
Expand Down
6 changes: 3 additions & 3 deletions src/Functional/Sum.php
Expand Up @@ -22,13 +22,13 @@
*/
namespace Functional;

use RecursiveIteratorIterator;
use RecursiveArrayIterator;
use Traversable;

/**
* Takes a collection and returns the sum of the elements
*
* @param \Traversable|array $collection
* @param Traversable|array $collection
* @param int $initial
* @return integer|float
*/
function sum($collection, $initial = 0)
Expand Down

0 comments on commit 901e167

Please sign in to comment.