Some refactoring.

This commit is contained in:
James Cole
2014-12-30 18:44:58 +01:00
parent 94fcfacec4
commit 8c3ae40de1
26 changed files with 327 additions and 329 deletions

View File

@@ -95,6 +95,29 @@ class ReportHelper implements ReportHelperInterface
return $one;
}
/**
* Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
public function sortArray(array $array)
{
uasort(
$array, function ($left, $right) {
if ($left['amount'] == $right['amount']) {
return 0;
}
return ($left['amount'] < $right['amount']) ? 1 : -1;
}
);
return $array;
}
/**
* Sort an array where all 'amount' keys are negative floats.
*
@@ -116,25 +139,4 @@ class ReportHelper implements ReportHelperInterface
return $array;
}
/**
* Sort an array where all 'amount' keys are positive floats.
*
* @param array $array
*
* @return array
*/
public function sortArray(array $array) {
uasort(
$array, function ($left, $right) {
if ($left['amount'] == $right['amount']) {
return 0;
}
return ($left['amount'] < $right['amount']) ? 1 : -1;
}
);
return $array;
}
}

View File

@@ -43,15 +43,6 @@ interface ReportHelperInterface
*/
public function mergeArrays(array $one, array $two);
/**
* Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
public function sortNegativeArray(array $array);
/**
* Sort an array where all 'amount' keys are positive floats.
*
@@ -61,4 +52,13 @@ interface ReportHelperInterface
*/
public function sortArray(array $array);
/**
* Sort an array where all 'amount' keys are negative floats.
*
* @param array $array
*
* @return array
*/
public function sortNegativeArray(array $array);
}

View File

@@ -44,8 +44,8 @@ class ReportQuery implements ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/
@@ -97,8 +97,8 @@ class ReportQuery implements ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/

View File

@@ -47,8 +47,8 @@ interface ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/
@@ -59,8 +59,8 @@ interface ReportQueryInterface
* and are balanced by a transfer to make up for it.
*
* @param \Account $account
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return Collection
*/