Skip to content

Commit f2cbd8c

Browse files
author
Jason Machado Silva
committed
Move shiftUp function to Custom Expression class.
1 parent f75b1c1 commit f2cbd8c

2 files changed

Lines changed: 24 additions & 10 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
}

Tools/Mapper/Mapper.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,6 @@ public function first(array $array)
194194
return reset($array);
195195
}
196196

197-
/**
198-
* @param array $elements
199-
*
200-
* @return array
201-
*/
202-
public function shiftUp(array $elements)
203-
{
204-
return array_merge(...$elements);
205-
}
206-
207197
/**
208198
* Convert a string to date.
209199
*

0 commit comments

Comments
 (0)