replace LESS library. fixes #4088
[dokuwiki.git] / vendor / splitbrain / lesserphp / src / Functions / Lists.php
blobe302de9951bac451703e09b342376555ebde6342
1 <?php
3 namespace LesserPHP\Functions;
5 use Exception;
6 use LesserPHP\Lessc;
7 use LesserPHP\Utils\Asserts;
9 /**
10 * Implements the list functions for LESS
12 * @link https://lesscss.org/functions/#list-functions
14 class Lists extends AbstractFunctionCollection
16 /** @inheritdoc */
17 public function getFunctions(): array
19 return [
20 //'length' => [$this, 'length'],
21 'extract' => [$this, 'extract'],
22 //'range' => [$this, 'range'],
23 //'each' => [$this, 'each'],
27 // length is missing
29 /**
30 * Returns the value at a specified position in a list
32 * @link https://lesscss.org/functions/#list-functions-extract
33 * @throws Exception
35 public function extract(array $value)
37 [$list, $idx] = Asserts::assertArgs($value, 2, 'extract');
38 $idx = Asserts::assertNumber($idx);
39 // 1 indexed
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?
47 // range is missing
49 // each is missing