Skip to content

Commit fdc77e9

Browse files
authored
Merge pull request #132 from smartboxgroup/feature/shift-array-up
Add function shiftUp
2 parents f99a8d8 + f2cbd8c commit fdc77e9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Tools/Evaluator/CustomExpressionLanguageProvider.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function getFunctions()
2929
$this->createStrtoupperFunction(),
3030
$this->createGetKeyFunction(),
3131
$this->createGetValueFunction(),
32+
$this->createShiftUpFunction()
3233
];
3334
}
3435

@@ -405,4 +406,27 @@ function ($arguments, $array) {
405406
}
406407
);
407408
}
409+
410+
/**
411+
* @param array $elements
412+
*
413+
* @return array
414+
*/
415+
protected function createShiftUpFunction()
416+
{
417+
return new ExpressionFunction(
418+
'shiftUp',
419+
function($array) {
420+
return sprintf('shiftUp(%s)', $array);
421+
},
422+
function ($arguments, $array) {
423+
if (!is_array($array)) {
424+
throw new \RuntimeException('Argument passed to "shiftUp" should be an array.');
425+
}
426+
427+
return array_merge(...$array);
428+
}
429+
);
430+
431+
}
408432
}

0 commit comments

Comments
 (0)