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


PHP Text::endsWith方法代码示例

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


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

示例1: env

 /**
  * Gets the value of an environment variable. Supports boolean, empty and null.
  *
  * @param  string $key
  * @param  mixed $default
  * @return mixed
  */
 function env($key, $default = null)
 {
     $value = getenv($key);
     if ($value === false) {
         return value($default);
     }
     switch (strtolower($value)) {
         case 'true':
         case '(true)':
             return true;
         case 'false':
         case '(false)':
             return false;
         case 'empty':
         case '(empty)':
             return '';
         case 'null':
         case '(null)':
             return;
     }
     if (Text::startsWith($value, '"') && Text::endsWith($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
开发者ID:xueron,项目名称:pails,代码行数:32,代码来源:helper.php

示例2: eager

 public function eager($model, $field = null, $localKey = null, $foreignKey = '_id')
 {
     if ($field == null || $localKey == null) {
         $className = strtolower((new \ReflectionClass($model))->getShortName());
         if (Text::endsWith($className, 's')) {
             $className = substr($className, 0, -1);
         }
     }
     if ($field == null) {
         $field = $className;
     }
     if ($localKey == null) {
         $localKey = $className . '_id';
     }
     $keys = [];
     foreach ($this->array as $item) {
         if (!in_array($item->{$localKey}, $keys)) {
             $keys[] = $item->{$localKey};
         }
     }
     $result = $model::init()->find([$foreignKey => ['$in' => $keys]])->keyBy('_id');
     foreach ($this->array as $item) {
         $item->setRelation($field, $result[(string) $item->{$localKey}]);
     }
     return $this;
 }
开发者ID:DenchikBY,项目名称:Phalcon-MongoDB-ODM,代码行数:26,代码来源:Collection.php

示例3: getIdFieldName

 protected function getIdFieldName($model)
 {
     $className = strtolower((new \ReflectionClass($model))->getShortName());
     if (Text::endsWith($className, 's')) {
         $className = substr($className, 0, -1);
     }
     return $className . '_id';
 }
开发者ID:DenchikBY,项目名称:Phalcon-MongoDB-ODM,代码行数:8,代码来源:Model.php

示例4: endsWith

 public static function endsWith($str, $end, $ignoreCase = true)
 {
     return parent::endsWith($str, $end, $ignoreCase);
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:4,代码来源:Text.php

示例5: testEndsWith

 public function testEndsWith()
 {
     $this->assertFalse(PhText::endsWith("", ""));
     $this->assertFalse(PhText::endsWith("", "hello"));
     $this->assertTrue(PhText::endsWith("Hello", "o"));
     $this->assertTrue(PhText::endsWith("Hello", "lo"));
     $this->assertTrue(PhText::endsWith("Hello", "Hello"));
     $this->assertFalse(PhText::endsWith("Hello", "LLO"));
     $this->assertFalse(PhText::endsWith("Hello", "hello"));
     $this->assertFalse(PhText::endsWith("Hello", "hello", true));
     $this->assertTrue(PhText::endsWith("Hello", "hello", false));
     $this->assertTrue(PhText::endsWith("Hello", "o", false));
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:13,代码来源:UnitTest.php

示例6: getOperations

 public function getOperations($controllerClass)
 {
     $operations = array();
     $ref = new \ReflectionClass($controllerClass);
     $methods = $ref->getMethods();
     $reader = new \Phalcon\Annotations\Adapter\Memory();
     $reflector = $reader->get($controllerClass);
     $operationAnnotations = $reflector->getMethodsAnnotations();
     foreach ($methods as $method) {
         if (!\Phalcon\Text::endsWith($method->name, 'Action')) {
             continue;
         }
         $operationKey = substr($method->name, 0, -6);
         $operationName = $operationKey;
         $operationDes = '';
         if (isset($operationAnnotations[$method->name]) && ($annotations = $operationAnnotations[$method->name])) {
             if (!$annotations->has('operationName') || !$annotations->has('operationDescription')) {
                 continue;
             }
             $annotation = $annotations->get('operationName');
             $operationName = implode('', $annotation->getArguments());
             $annotation = $annotations->get('operationDescription');
             $operationDes = implode('', $annotation->getArguments());
         }
         $operation = array('name' => $operationName, 'resourceKey' => $controllerClass, 'operationKey' => $operationKey, 'description' => $operationDes);
         $operations[] = $operation;
     }
     return $operations;
 }
开发者ID:skybird,项目名称:phalcon,代码行数:29,代码来源:Scanner.php

示例7: endsWith

 public static function endsWith($str, $end, $ignoreCase = null)
 {
     return Text::endsWith($str, $end, $ignoreCase);
 }
开发者ID:aleboisselier,项目名称:phalcon-jquery,代码行数:4,代码来源:PhalconUtils.php

示例8: boot

 public function boot(Container $container)
 {
     // Pails 不使用Phalcon的Module功能,通过Namespace组织Controllers.
     // 如果出现多级,比如AdminApi,则一定要以Namespace的形式组织 Admin\Api\xxxxController
     //
     // Note: from phalcon 3, closure bind di as $this by default. so no use($app) needed.
     //
     $container->setShared('router', function () {
         //
         $router = new Annotations(false);
         $router->removeExtraSlashes(true);
         $router->setEventsManager($this->get('eventsManager'));
         $router->setDefaultNamespace('App\\Controllers');
         $router->setDefaultController('application');
         $router->setDefaultAction('index');
         // Process /config/routes.php
         // Verb	        Path	            Action	Route Name
         // GET	        /photo	            index	photo.index
         // GET	        /photo/create	    create	photo.create
         // POST	        /photo	            store	photo.store
         // GET	        /photo/{photo}	    show	photo.show
         // GET	        /photo/{photo}/edit	edit	photo.edit
         // PUT/PATCH	/photo/{photo}	    update	photo.update
         // DELETE	    /photo/{photo}	    destroy	photo.destroy
         foreach ($this->getConfig('routes') as $url => $route) {
             //                $resourceDefaults = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy'];
             //
             //                // a RESTful resource
             //                if (isset($route['resource'])) {
             //                    if (!isset($route[''])) {}
             //                    foreach ($this->getResourceMethods($defaults, $options) as $m) {
             //                        $this->{'addResource'.ucfirst($m)}($url, $route, $options);
             //                    }
             //                } else {
             //                    if (count($route) !== count($route, COUNT_RECURSIVE)) {
             //                        if (isset($route['pattern']) && isset($route['paths'])) {
             //                            $method = isset($route['httpMethods']) ? $route['httpMethods'] : null;
             //                            $router->add($route['pattern'], $route['paths'], $method);
             //                        } else {
             //                            throw new \RuntimeException(sprintf('No route pattern and paths found by route %s', $url));
             //                        }
             //                    } else {
             //                        $router->add($url, $route);
             //                    }
             //                }
         }
         // 定义注解路由
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path('Controllers')), \RecursiveIteratorIterator::SELF_FIRST);
         foreach ($iterator as $item) {
             if (Text::endsWith($item, "Controller.php", false)) {
                 $name = str_replace([$this->path('Controllers') . DIRECTORY_SEPARATOR, "Controller.php"], "", $item);
                 $name = str_replace(DIRECTORY_SEPARATOR, "\\", $name);
                 $router->addResource('App\\Controllers\\' . $name);
             }
         }
         // 定义404路由
         $router->notFound(["controller" => "application", "action" => "notfound"]);
         //
         return $router;
     });
 }
开发者ID:xueron,项目名称:pails,代码行数:61,代码来源:Router.php

示例9: testEndsWithException

 public function testEndsWithException()
 {
     $this->setExpectedException('\\Phalcon\\Exception');
     \Phalcon\Text::endsWith(false, 'he');
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:5,代码来源:TextTest.php


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