当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::match方法代码示例

本文整理汇总了PHP中Str::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::match方法的具体用法?PHP Str::match怎么用?PHP Str::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


在下文中一共展示了Str::match方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
 }
开发者ID:innmind,项目名称:crawler,代码行数:26,代码来源:IosParser.php

示例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')));
 }
开发者ID:innmind,项目名称:rest-client,代码行数:8,代码来源:SetType.php

示例3: buildCondition

 private function buildCondition(ComparatorInterface $specification) : SequenceInterface
 {
     $property = new Str($specification->property());
     switch (true) {
         case $this->meta->properties()->contains($specification->property()):
             return $this->buildPropertyCondition($specification);
         case $property->match('/[a-zA-Z]+(\\.[a-zA-Z]+)+/'):
             return $this->buildSubPropertyCondition($specification);
     }
 }
开发者ID:innmind,项目名称:neo4j-onm,代码行数:10,代码来源:AggregateVisitor.php

示例4: fromString

 /**
  * Build an object out of a string
  *
  * @param string $string
  *
  * @return self
  */
 public static function fromString(string $string) : self
 {
     $string = new Str($string);
     $pattern = sprintf('~%s/[\\w\\-.]+(\\+\\w+)?([;,] [\\w\\-.]+=[\\w\\-.]+)?~', self::topLevels()->join('|'));
     if (!$string->match($pattern)) {
         throw new InvalidMediaTypeStringException();
     }
     $splits = $string->pregSplit('~[;,] ~');
     $matches = $splits->get(0)->getMatches(sprintf('~^(?<topLevel>%s)/(?<subType>[\\w\\-.]+)(\\+(?<suffix>\\w+))?$~', self::topLevels()->join('|')));
     $topLevel = $matches->get('topLevel');
     $subType = $matches->get('subType');
     $suffix = $matches->hasKey('suffix') ? $matches->get('suffix') : '';
     $params = new Map('string', ParameterInterface::class);
     $splits->shift()->each(function (int $idx, Str $param) use(&$params) {
         $matches = $param->getMatches('~^(?<key>[\\w\\-.]+)=(?<value>[\\w\\-.]+)$~');
         $params = $params->put((string) $matches->get('key'), new Parameter((string) $matches->get('key'), (string) $matches->get('value')));
     });
     return new self((string) $topLevel, (string) $subType, (string) $suffix, $params);
 }
开发者ID:innmind,项目名称:filesystem,代码行数:26,代码来源:MediaType.php

示例5: referer_match

 /**
  * Проверяет адрес страницы которая привела пользователя на текущую страницу с шаблоном по "звездочке"
  *
  * @param string $pattern - путь с маской
  * @return boolean
  */
 public static function referer_match($pattern)
 {
     return Str::match($pattern, static::referer());
 }
开发者ID:AlexanderGrom,项目名称:knee,代码行数:10,代码来源:request.php


注:本文中的Str::match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。