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


PHP StringUtils::endsWith方法代码示例

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


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

示例1: testEndsWith

 /**
  * Test for Schwaen\Stdlib\StringUtils::endsWith
  */
 public function testEndsWith()
 {
     $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'welt'));
     $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', 'Welt'));
     $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'Test'));
     $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', ''));
 }
开发者ID:schwaen,项目名称:stdlib,代码行数:10,代码来源:StringUtilsTest.php

示例2: extractMainDomainFromUrl

 /**
  * Extract the domain from a url
  *
  * @param string $url
  *
  * @return string
  */
 public static function extractMainDomainFromUrl($url)
 {
     $matchesMainDomain = null;
     $hostString = self::urlToString($url);
     $pattern = '/[^.]+\\.[^.]+$/';
     foreach (self::$excludedTld as $extension) {
         if (StringUtils::endsWith($hostString, $extension)) {
             $pattern = sprintf('/.*\\.(.*%s)/', str_replace('.', '\\.', $extension));
             break;
         }
     }
     preg_match($pattern, $hostString, $matchesMainDomain);
     $mainDomain = array_pop($matchesMainDomain);
     return $mainDomain;
 }
开发者ID:Neirda24,项目名称:tools-bundle,代码行数:22,代码来源:UrlUtils.php

示例3: processAspects

 /**
  * Adds all the plugin's aspects
  *
  * @param Plugin $plugin The plugin to analyze
  * @param string &$log   A variable that will get logging detail appended
  *
  * @return void
  */
 public function processAspects(Plugin $plugin, &$log = '')
 {
     $anyChanged = false;
     $processedSlugs = array();
     $pluginPath = $plugin->Path;
     $aspectsPath = $pluginPath . '/aspects';
     if (file_exists($aspectsPath)) {
         $iter = new DirectoryIterator($aspectsPath);
         foreach ($iter as $aspectFile) {
             if ($aspectFile->isFile() && StringUtils::endsWith($aspectFile->getBasename(), '.xml')) {
                 $aspectSlug = $aspectFile->getBasename(".xml");
                 try {
                     $log .= "Processing aspect descriptor: {$aspectFile->getBasename()}\n";
                     $ts = $this->DateFactory->newLocalDate(filemtime($aspectFile->getPathname()));
                     $md5 = md5_file($aspectFile->getPathname());
                     if ($this->AspectService->slugExists($aspectSlug)) {
                         $aspect = $this->AspectService->getBySlug($aspectSlug);
                         if ($aspect->Md5 !== $md5) {
                             $aspectXML = $this->SimpleXMLParser->parseXMLFile($aspectFile->getPathname());
                             if ($aspectXML == false) {
                                 throw new Exception('Unable to load aspect XML [' . $aspectFile->getPathname() . ']');
                             }
                             $aspect = $this->SystemXMLConverter->xmlToAspect($aspect, $aspectXML);
                             if ($aspect->PluginID != $plugin->PluginID) {
                                 throw new Exception('Aspect installed by another plugin: ' . $aspect->Slug);
                             }
                             $aspect->ModifiedDate = $ts;
                             $aspect->Md5 = $md5;
                             $log .= "Aspect updated...\n";
                             $this->AspectService->edit($aspect);
                             $anyChanged = true;
                         }
                     } else {
                         $aspectXML = $this->SimpleXMLParser->parseXMLFile($aspectFile->getPathname());
                         if ($aspectXML == false) {
                             throw new Exception('Unable to load aspect XML [' . $aspectFile->getPathname() . ']');
                         }
                         $aspect = new Aspect();
                         $this->ModelMapper->defaultsOnModel($aspect);
                         $aspect = $this->SystemXMLConverter->xmlToAspect($aspect, $aspectXML);
                         $aspect->Slug = $aspectSlug;
                         $aspect->PluginID = $plugin->PluginID;
                         $aspect->ModifiedDate = $ts;
                         $aspect->Md5 = $md5;
                         $log .= "Aspect created...\n";
                         $this->AspectService->add($aspect);
                         $anyChanged = true;
                     }
                     // resolve schema
                     if ($aspect->getXMLSchema() != "") {
                         $schemaXML = "<?xml version='1.0'?><schema>";
                         $schemaXML .= preg_replace('/\\<\\?xml([^\\>\\/]*)\\>/', '', $aspect->getXMLSchema());
                         $schemaXML .= "</schema>";
                         try {
                             $this->NodeSchemaParser->parse($schemaXML);
                         } catch (Exception $e) {
                             throw new SchemaException("Unable to parse schema for aspect [{$aspect->Slug}]:\n " . $e->getMessage());
                         }
                     }
                     $this->AspectService->getBySlug($aspect->Slug);
                     $log .= "ID: {$aspect->AspectID}\n";
                     $log .= "Slug: {$aspect->Slug}\n";
                     $log .= "Name: {$aspect->Name}\n";
                     $log .= "Description: {$aspect->Description}\n";
                     $log .= "Md5: {$aspect->Md5}\n";
                     $log .= "\n";
                 } catch (ValidationException $ve) {
                     throw new Exception('Aspect [' . $aspectSlug . ']: ' . $ve->getMessage());
                 }
                 $processedSlugs[] = $aspectSlug;
             }
         }
     }
     if ($plugin->PluginID == '') {
         return $anyChanged;
     }
     $existing = $this->AspectService->findAll(new DTO(array('PluginID' => $plugin->PluginID)))->getResults();
     foreach ($existing as $e) {
         if (!in_array($e->Slug, $processedSlugs)) {
             $this->AspectService->delete($e->Slug);
         }
     }
     return $anyChanged;
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion,代码行数:92,代码来源:PluginInstallationService.php

示例4: _importPhotosFromDir

 protected function _importPhotosFromDir($dir)
 {
     $h = opendir($dir);
     while (($fname = readdir($h)) !== FALSE) {
         if (StringUtils::endsWith(strtolower($fname), '.jpg')) {
             try {
                 echo "importing {$fname}...";
                 $nodeRef = $this->NodeRefService->oneFromAspect('@images');
                 $nodeRef = $this->NodeRefService->generateNodeRef($nodeRef, $fname);
                 $node = $nodeRef->generateNode();
                 $node->Title = $fname;
                 $node->Status = "published";
                 $node->ActiveDate = $this->DateFactory->newStorageDate();
                 $node = $this->ImageService->storeMedia(rtrim($dir, '/') . '/' . $fname, $node);
                 $this->NodeService->add($node);
                 echo "done\n";
                 unset($nodeRef);
                 unset($node);
             } catch (Exception $e) {
                 echo "Exception: " . $e->getMessage() . "\n";
             }
         }
     }
     closedir($h);
 }
开发者ID:wb-crowdfusion,项目名称:crowdfusion-advanced-media,代码行数:25,代码来源:MediaCliController.php


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