Skip to content

Commit

Permalink
Change extension's methods to static
Browse files Browse the repository at this point in the history
  • Loading branch information
dpolac committed May 5, 2016
1 parent fd2e572 commit 9289bea
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions LambdaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public function getOperators()
public function getFunctions()
{
return [
new \Twig_SimpleFunction('call', [$this, 'call']),
new \Twig_SimpleFunction('call', '\DPolac\TwigLambda\LambdaExtension::call'),
];
}

public function getTests()
{
return [
new \Twig_SimpleTest('every', '\Underscore\Types\Arrays::matches'),
new \Twig_SimpleTest('any', [$this, 'any']),
new \Twig_SimpleTest('any', '\DPolac\TwigLambda\LambdaExtension::any'),
];
}

Expand All @@ -56,11 +56,11 @@ public function getFilters()

new \Twig_SimpleFilter('group_by', '\Underscore\Types\Arrays::group'),
new \Twig_SimpleFilter('sort_by', '\Underscore\Types\Arrays::sort'),
new \Twig_SimpleFilter('count_by', [$this, 'countBy']),
new \Twig_SimpleFilter('count_by', '\DPolac\TwigLambda\LambdaExtension::countBy'),
];
}

public function countBy(array $array, $callback)
public static function countBy(array $array, $callback)
{
$result = [];
foreach ($array as $element) {
Expand All @@ -79,7 +79,7 @@ public function countBy(array $array, $callback)
return $result;
}

public function any(array $array, $callback)
public static function any(array $array, $callback)
{
if (!is_callable($callback)) {
throw new \InvalidArgumentException(
Expand All @@ -93,7 +93,7 @@ public function any(array $array, $callback)
return Arrays::matchesAny($array, $callback);
}

public function call($callback, array $args = [])
public static function call($callback, array $args = [])
{
if (!is_callable($callback)) {
throw new \InvalidArgumentException('First argument must be callable.');
Expand Down

0 comments on commit 9289bea

Please sign in to comment.