3 namespace LesserPHP\Functions
;
7 use LesserPHP\Utils\Asserts
;
10 * Implements the list functions for LESS
12 * @link https://lesscss.org/functions/#list-functions
14 class Lists
extends AbstractFunctionCollection
17 public function getFunctions(): array
20 //'length' => [$this, 'length'],
21 'extract' => [$this, 'extract'],
22 //'range' => [$this, 'range'],
23 //'each' => [$this, 'each'],
30 * Returns the value at a specified position in a list
32 * @link https://lesscss.org/functions/#list-functions-extract
35 public function extract(array $value)
37 [$list, $idx] = Asserts
::assertArgs($value, 2, 'extract');
38 $idx = Asserts
::assertNumber($idx);
40 if ($list[0] == 'list' && isset($list[2][$idx - 1])) {
41 return $list[2][$idx - 1];
44 // FIXME what is the expected behavior here? Apparently it's not an error?