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


PHP Strings::contains方法代码示例

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


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

示例1: encode

 /**
  * Returns the NEON representation of a value.
  * @param  mixed
  * @param  int
  * @return string
  */
 public static function encode($var, $options = NULL)
 {
     if ($var instanceof DateTime) {
         return $var->format('Y-m-d H:i:s O');
     } elseif ($var instanceof NeonEntity) {
         return self::encode($var->value) . '(' . substr(self::encode($var->attributes), 1, -1) . ')';
     }
     if (is_object($var)) {
         $obj = $var;
         $var = array();
         foreach ($obj as $k => $v) {
             $var[$k] = $v;
         }
     }
     if (is_array($var)) {
         $isList = Validators::isList($var);
         $s = '';
         if ($options & self::BLOCK) {
             if (count($var) === 0) {
                 return "[]";
             }
             foreach ($var as $k => $v) {
                 $v = self::encode($v, self::BLOCK);
                 $s .= ($isList ? '-' : self::encode($k) . ':') . (Strings::contains($v, "\n") ? "\n\t" . str_replace("\n", "\n\t", $v) : ' ' . $v) . "\n";
                 continue;
             }
             return $s;
         } else {
             foreach ($var as $k => $v) {
                 $s .= ($isList ? '' : self::encode($k) . ': ') . self::encode($v) . ', ';
             }
             return ($isList ? '[' : '{') . substr($s, 0, -2) . ($isList ? ']' : '}');
         }
     } elseif (is_string($var) && !is_numeric($var) && !preg_match('~[\\x00-\\x1F]|^\\d{4}|^(true|false|yes|no|on|off|null)$~i', $var) && preg_match('~^' . self::$patterns[4] . '$~', $var)) {
         return $var;
     } elseif (is_float($var)) {
         $var = var_export($var, TRUE);
         return Strings::contains($var, '.') ? $var : $var . '.0';
     } else {
         return json_encode($var);
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:48,代码来源:Neon.php

示例2: getKernelClasses

 /**
  * Search for commmand classes of kernel
  */
 public static function getKernelClasses()
 {
     $classes = array();
     //
     $namespace = "AR\\Kernel\\Console\\Commands";
     //
     foreach (get_declared_classes() as $value) {
         if (\Strings::contains($value, $namespace)) {
             $classes[] = $value;
         }
     }
     return $classes;
 }
开发者ID:ar-framework-labs,项目名称:kernel,代码行数:16,代码来源:Console.php

示例3: macroContentType

 /**
  * {contentType ...}
  */
 public function macroContentType(MacroNode $node, PhpWriter $writer)
 {
     if (Strings::contains($node->args, 'xhtml')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_XHTML);
     } elseif (Strings::contains($node->args, 'html')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_HTML);
     } elseif (Strings::contains($node->args, 'xml')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_XML);
     } elseif (Strings::contains($node->args, 'javascript')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_JS);
     } elseif (Strings::contains($node->args, 'css')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_CSS);
     } elseif (Strings::contains($node->args, 'calendar')) {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_ICAL);
     } else {
         $this->getCompiler()->setContentType(LatteCompiler::CONTENT_TEXT);
     }
     // temporary solution
     if (Strings::contains($node->args, '/')) {
         return $writer->write('$netteHttpResponse->setHeader("Content-Type", %var)', $node->args);
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:25,代码来源:UIMacros.php

示例4: getServiceName

 /**
  * Converts @service or @Class -> service name and checks its existence.
  * @param  mixed
  * @return string  of FALSE, if argument is not service name
  */
 public function getServiceName($arg, $self = NULL)
 {
     if (!is_string($arg) || !preg_match('#^@[\\w\\\\.].+$#', $arg)) {
         return FALSE;
     }
     $service = substr($arg, 1);
     if ($service === self::CREATED_SERVICE) {
         $service = $self;
     }
     if (Strings::contains($service, '\\')) {
         if ($this->classes === FALSE) {
             // may be disabled by prepareClassList
             return $service;
         }
         $res = $this->getByType($service);
         if (!$res) {
             throw new ServiceCreationException("Reference to missing service of type {$service}.");
         }
         return $res;
     }
     if (!isset($this->definitions[$service])) {
         throw new ServiceCreationException("Reference to missing service '{$service}'.");
     }
     return $service;
 }
开发者ID:riskatlas,项目名称:micka,代码行数:30,代码来源:ContainerBuilder.php

示例5: processHtmlTagEnd

 private function processHtmlTagEnd(LatteToken $token)
 {
     if ($token->text === '-->') {
         $this->output .= $token->text;
         $this->setContext(NULL);
         return;
     }
     $htmlNode = end($this->htmlNodes);
     $isEmpty = !$htmlNode->closing && (Strings::contains($token->text, '/') || $htmlNode->isEmpty);
     if ($isEmpty && in_array($this->contentType, array(self::CONTENT_HTML, self::CONTENT_XHTML))) {
         // auto-correct
         $token->text = preg_replace('#^.*>#', $this->contentType === self::CONTENT_XHTML ? ' />' : '>', $token->text);
     }
     if (empty($htmlNode->macroAttrs)) {
         $this->output .= $token->text;
     } else {
         $code = substr($this->output, $htmlNode->offset) . $token->text;
         $this->output = substr($this->output, 0, $htmlNode->offset);
         $this->writeAttrsMacro($code, $htmlNode);
         if ($isEmpty) {
             $htmlNode->closing = TRUE;
             $this->writeAttrsMacro('', $htmlNode);
         }
     }
     if ($isEmpty) {
         $htmlNode->closing = TRUE;
     }
     if (!$htmlNode->closing && (strcasecmp($htmlNode->name, 'script') === 0 || strcasecmp($htmlNode->name, 'style') === 0)) {
         $this->setContext(strcasecmp($htmlNode->name, 'style') ? self::CONTENT_JS : self::CONTENT_CSS);
     } else {
         $this->setContext(NULL);
         if ($htmlNode->closing) {
             array_pop($this->htmlNodes);
         }
     }
 }
开发者ID:riskatlas,项目名称:micka,代码行数:36,代码来源:Compiler.php

示例6: date

 /**
  * Date/time formatting.
  * @param  string|int|DateTime
  * @param  string
  * @return string
  */
 public static function date($time, $format = NULL)
 {
     if ($time == NULL) {
         // intentionally ==
         return NULL;
     }
     if (!isset($format)) {
         $format = self::$dateFormat;
     }
     $time = DateTime53::from($time);
     return Strings::contains($format, '%') ? strftime($format, $time->format('U')) : $time->format($format);
     // formats using date()
 }
开发者ID:riskatlas,项目名称:micka,代码行数:19,代码来源:Helpers.php


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