Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
possiblelengthfield.php
1<?php
2
4
6
8{
9 public function decodeValue($value)
10 {
11 return static::parsePossibleLength($value);
12 }
13
19 public static function parsePossibleLength($possibleLength)
20 {
21 $result = array();
22 $tokens = explode(',', $possibleLength);
23 foreach ($tokens as $token)
24 {
25 if(preg_match('/^\d+$/', $token))
26 {
27 $result[] = (int)$token;
28 }
29 else if(preg_match('/^\[(\d+)-(\d+)\]$/', $token, $matches))
30 {
31 $start = $matches[1];
32 $end = $matches[2];
33 $result = array_merge($result, range($start, $end));
34 }
35 else
36 {
37 throw new SystemException("Unrecognized token: ", $token);
38 }
39 }
40 return $result;
41 }
42
43}