public static function fromString($value) { if ($value === '*') { return new static(NULL, true); } return new static(EntityTag::fromString($value)); }
public static function fromString($value) { $lists = []; $m = NULL; if (preg_match_all("'\\s*(?:<(?<resource>[^>]+)>)?\\s*\\(\\s*(?<list>[^\\)]+)\\s*\\)'", $value, $m)) { $resource = ''; for ($size = count($m[0]), $i = 0; $i < $size; $i++) { if (!empty($m['resource'][$i])) { $resource = $m['resource'][$i]; } $conditions = []; $uri = NULL; if (preg_match_all("'(?<not>not)?\\s*<urn:webdav:(?<type>[^:]+):(?<token>[a-f0-9\\-]{36})>'i", $m['list'][$i], $uri)) { for ($size2 = count($uri[0]), $j = 0; $j < $size2; $j++) { $not = !empty($uri['not'][$j]); $type = strtolower($uri['type'][$j]); try { $uuid = new UUID($uri['token'][$j]); } catch (\InvalidArgumentException $e) { if (!$not) { throw $e; } } switch (strtolower($type)) { case 'lock': $conditions[] = new IfLockTokenCondition($uuid, $not); continue 2; case 'sync': $conditions[] = new IfSyncTokenCondition($uuid, $not); continue 2; } if (!$not) { throw new \InvalidArgumentException(sprintf('Unsupported WebDAV token type: "%s"', $type)); } } } $etags = NULL; if (preg_match_all("'(?<not>not)?\\s*\\[(?<etag>\"[^\"]*\")\\]'i", $m['list'][$i], $etags)) { for ($size2 = count($etags[0]), $j = 0; $j < $size2; $j++) { $not = !empty($etags['not'][$j]); try { $conditions[] = new IfEntityTagCondition(EntityTag::fromString($etags['etag'][$j]), $not); } catch (\InvalidArgumentException $e) { if (!$not) { throw $e; } } } } $lists[] = new IfConditionList($resource, $conditions); } } return new static($lists); }
public static function fromString($value) { return new static(EntityTag::fromString($value)); }