本文整理汇总了PHP中Str::getMatches方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::getMatches方法的具体用法?PHP Str::getMatches怎么用?PHP Str::getMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::getMatches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public function parse(RequestInterface $request, ResponseInterface $response, MapInterface $attributes) : MapInterface
{
$start = $this->clock->now();
if (!$this->isHtml($attributes)) {
return $attributes;
}
$document = $this->reader->read($response->body());
try {
$metas = (new Elements('meta'))((new Head())($document));
} catch (ElementNotFoundException $e) {
return $attributes;
}
$meta = $metas->filter(function (ElementInterface $meta) : bool {
return $meta->attributes()->contains('name') && $meta->attributes()->get('name')->value() === 'apple-itunes-app' && $meta->attributes()->contains('content');
});
if ($meta->size() !== 1) {
return $attributes;
}
$content = $meta->current()->attributes()->get('content')->value();
$content = new Str($content);
if (!$content->match(self::PATTERN)) {
return $attributes;
}
$matches = $content->getMatches(self::PATTERN);
return $attributes->put(self::key(), new Attribute(self::key(), (string) $matches['uri'], $this->clock->now()->elapsedSince($start)->milliseconds()));
}
示例2: fromString
public static function fromString(string $type, Types $types) : TypeInterface
{
$type = new Str($type);
if (!$type->match(self::PATTERN)) {
throw new InvalidArgumentException();
}
return new self($types->build((string) $type->getMatches(self::PATTERN)->get('inner')));
}
示例3: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'content-type') {
throw new InvalidArgumentException();
}
$matches = $value->getMatches('~(?<type>[\\w*]+)/(?<subType>[\\w*]+)(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?~');
return new ContentType(new ContentTypeValue((string) $matches->get('type'), (string) $matches->get('subType'), $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''))));
}