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


PHP Str::split方法代码示例

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


在下文中一共展示了Str::split方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildSubPropertyCondition

 private function buildSubPropertyCondition(ComparatorInterface $specification) : SequenceInterface
 {
     $prop = new Str($specification->property());
     $pieces = $prop->split('.');
     $var = (new Str('entity_'))->append($pieces->pop()->join('_'));
     $key = $var->append('_')->append((string) $pieces->last())->append((string) $this->count);
     return new Sequence(sprintf('%s %s %s', $var->append('.')->append((string) $pieces->last()), $specification->sign(), $key->prepend('{')->append('}')), new Collection([(string) $key => $specification->value()]));
 }
开发者ID:innmind,项目名称:neo4j-onm,代码行数:8,代码来源:AggregateVisitor.php

示例2: buildSubPropertyMapping

 private function buildSubPropertyMapping(ComparatorInterface $specification) : MapInterface
 {
     $prop = new Str($specification->property());
     $pieces = $prop->split('.');
     $var = (new Str('entity_'))->append($pieces->pop()->join('_'));
     $key = $var->append('_')->append((string) $pieces->last());
     return (new Map('string', SequenceInterface::class))->put((string) $var, new Sequence(new Collection([(string) $pieces->last() => (string) $key->prepend('{')->append('}')]), new Collection([(string) $key => $specification->value()])));
 }
开发者ID:innmind,项目名称:neo4j-onm,代码行数:8,代码来源:AggregateVisitor.php

示例3: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'content-language') {
         throw new InvalidArgumentException();
     }
     $values = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $language) {
         $values = $values->add(new ContentLanguageValue((string) $language->trim()));
     }
     return new ContentLanguage($values);
 }
开发者ID:innmind,项目名称:http,代码行数:11,代码来源:ContentLanguageFactory.php

示例4: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'allow') {
         throw new InvalidArgumentException();
     }
     $values = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $allow) {
         $values = $values->add(new AllowValue((string) $allow->trim()->toUpper()));
     }
     return new Allow($values);
 }
开发者ID:innmind,项目名称:http,代码行数:11,代码来源:AllowFactory.php

示例5: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'accept-language') {
         throw new InvalidArgumentException();
     }
     $values = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $accept) {
         $matches = $accept->getMatches('~(?<lang>([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*|\\*))(; ?q=(?<quality>\\d+(\\.\\d+)?))?~');
         $values = $values->add(new AcceptLanguageValue((string) $matches->get('lang'), new Quality($matches->hasKey('quality') ? (double) (string) $matches->get('quality') : 1)));
     }
     return new AcceptLanguage($values);
 }
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptLanguageFactory.php

示例6: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'accept') {
         throw new InvalidArgumentException();
     }
     $values = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $accept) {
         $matches = $accept->getMatches('~(?<type>[\\w*]+)/(?<subType>[\\w*]+)(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?~');
         $values = $values->add(new AcceptValue((string) $matches->get('type'), (string) $matches->get('subType'), $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''))));
     }
     return new Accept($values);
 }
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptFactory.php

示例7: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'accept-charset') {
         throw new InvalidArgumentException();
     }
     $values = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $accept) {
         $matches = $accept->getMatches('~(?<charset>[a-zA-Z0-9\\-_:\\(\\)]+)(; ?q=(?<quality>\\d+(\\.\\d+)?))?~');
         $values = $values->add(new AcceptCharsetValue((string) $matches->get('charset'), new Quality($matches->hasKey('quality') ? (double) (string) $matches->get('quality') : 1)));
     }
     return new AcceptCharset($values);
 }
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptCharsetFactory.php

示例8: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'cache-control') {
         throw new InvalidArgumentException();
     }
     $splits = $value->split(',');
     $values = new Set(HeaderValueInterface::class);
     foreach ($splits as $split) {
         $split = $split->trim();
         switch (true) {
             case $split->match('~^max-age=\\d+$~'):
                 $values = $values->add(new CacheControlValue\MaxAge((int) (string) $split->substring(8)));
                 break;
             case $split->match('~^max-stale(=\\d+)?$~'):
                 $values = $values->add(new CacheControlValue\MaxStale($split->length() > 10 ? (int) (string) $split->substring(10) : 0));
                 break;
             case $split->match('~^min-fresh=\\d+$~'):
                 $values = $values->add(new CacheControlValue\MinimumFresh((int) (string) $split->substring(10)));
                 break;
             case (string) $split === 'must-revalidate':
                 $values = $values->add(new CacheControlValue\MustRevalidate());
                 break;
             case $split->match('~^no-cache(="?\\w+"?)?$~'):
                 $matches = $split->getMatches('~^no-cache(="?(?<field>\\w+)"?)?$~');
                 $values = $values->add(new CacheControlValue\NoCache($matches->hasKey('field') ? (string) $matches->get('field') : ''));
                 break;
             case (string) $split === 'no-store':
                 $values = $values->add(new CacheControlValue\NoStore());
                 break;
             case (string) $split === 'no-transform':
                 $values = $values->add(new CacheControlValue\NoTransform());
                 break;
             case (string) $split === 'only-if-cached':
                 $values = $values->add(new CacheControlValue\OnlyIfCached());
                 break;
             case $split->match('~^private(="?\\w+"?)?$~'):
                 $matches = $split->getMatches('~^private(="?(?<field>\\w+)"?)?$~');
                 $values = $values->add(new CacheControlValue\PrivateCache($matches->hasKey('field') ? (string) $matches->get('field') : ''));
                 break;
             case (string) $split === 'proxy-revalidate':
                 $values = $values->add(new CacheControlValue\ProxyRevalidate());
                 break;
             case (string) $split === 'public':
                 $values = $values->add(new CacheControlValue\PublicCache());
                 break;
             case $split->match('~^s-maxage=\\d+$~'):
                 $values = $values->add(new CacheControlValue\SharedMaxAge((int) (string) $split->substring(9)));
                 break;
         }
     }
     return new CacheControl($values);
 }
开发者ID:innmind,项目名称:http,代码行数:52,代码来源:CacheControlFactory.php

示例9: make

 public function make(Str $name, Str $value) : HeaderInterface
 {
     if ((string) $name->toLower() !== 'link') {
         throw new InvalidArgumentException();
     }
     $links = new Set(HeaderValueInterface::class);
     foreach ($value->split(',') as $link) {
         $matches = $link->trim()->getMatches('~^<(?<url>\\S+)>(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?$~');
         $params = $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''));
         $links = $links->add(new LinkValue(Url::fromString((string) $matches->get('url')), $params->contains('rel') ? $params->get('rel')->value() : 'related', $params->contains('rel') ? $params->remove('rel') : $params));
     }
     return new Link($links);
 }
开发者ID:innmind,项目名称:http,代码行数:13,代码来源:LinkFactory.php


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