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


PHP Str::endsWith方法代码示例

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


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

示例1: removeTrailingSlash

 protected function removeTrailingSlash($path)
 {
     if (Str::endsWith($path, '/') && $path != '/') {
         unset($path[strlen($path) - 1]);
     }
     return $path;
 }
开发者ID:airondumael,项目名称:api-generator,代码行数:7,代码来源:BaseCreator.php

示例2: 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 (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
开发者ID:lchski,项目名称:api.lucascherkewski.com,代码行数:33,代码来源:helpers.php

示例3: getConfigPathFile

 public final function getConfigPathFile($file)
 {
     if (!Str::endsWith($file, '.php')) {
         $file = $file . '.php';
     }
     return config_path($this->getConfigShortPath() . '/' . $file);
 }
开发者ID:marcmascarell,项目名称:laravel-artificer,代码行数:7,代码来源:PublicVendorPaths.php

示例4: postProcessRules

 /**
  * @param array $rules
  *
  * @return callable[]
  * @throws Exception
  */
 public function postProcessRules(array &$rules)
 {
     $postProcessors = [];
     $hasArrayRule = false;
     foreach ($rules as $attribute => &$attributeRules) {
         foreach ($attributeRules as $ruleIndex => &$ruleData) {
             list($ruleName, $ruleParams) = $this->parseRule($ruleData);
             if ('array' == $ruleName) {
                 $hasArrayRule = true;
             }
             if (!Str::endsWith($ruleName, '[]')) {
                 continue;
             }
             $ruleName = substr($ruleName, 0, -2);
             if (Str::endsWith($ruleName, '[]')) {
                 throw new Exception("Error in rule '{$ruleName}' for attribute '{$attribute}'. Multidimensional arrays are not currently supported");
             }
             if ($hasArrayRule) {
                 unset($attributeRules[$ruleIndex]);
             } else {
                 $ruleData = ['array', []];
             }
             $postProcessors[] = function (Validator $validator) use($attribute, $ruleName, $ruleParams) {
                 $validator->each($attribute, [$ruleName . ':' . implode(', ', $ruleParams)]);
             };
         }
     }
     return $postProcessors;
 }
开发者ID:fhteam,项目名称:laravel-validator,代码行数:35,代码来源:ArrayRulePostProcessor.php

示例5: replaceParagraphsByBr

 private function replaceParagraphsByBr($html)
 {
     $html = preg_replace("/<p[^>]*?>/", "", $html);
     $html = trim(str_replace("</p>", "<br />", $html));
     if (Str::endsWith($html, "<br />")) {
         $html = substr($html, 0, strlen($html) - strlen("<br />"));
     }
     return $html;
 }
开发者ID:oimken,项目名称:sharp,代码行数:9,代码来源:SharpWordLimitRenderer.php

示例6: purge

 /**
  * Purges confirmation fields from the attributes.
  *
  * @return void
  */
 public function purge()
 {
     foreach ($this->attributes as $k => $attr) {
         // If the attribute ends in "_confirmation"
         if (Str::endsWith($k, '_confirmation')) {
             // We unset the value
             unset($this->attributes[$k]);
         }
     }
 }
开发者ID:ronaldcastillo,项目名称:base,代码行数:15,代码来源:Purge.php

示例7: get

 /**
  * Get unique random filename with $extenstion within $path directory
  * @param string $path
  * @param string $extension
  * @return string
  */
 public static function get($path, $extension)
 {
     if (!Str::endsWith($path, '/')) {
         $path .= '/';
     }
     do {
         $name = Str::random(10) . '.' . $extension;
     } while (file_exists($path . $name));
     return $name;
 }
开发者ID:GlobalsDD,项目名称:admin,代码行数:16,代码来源:RandomFilenamer.php

示例8: loadFilesRecursively

 protected function loadFilesRecursively($path)
 {
     foreach ($this->files->files($path) as $file) {
         if (Str::endsWith($file, '.php')) {
             require_once $file;
         }
     }
     foreach ($this->files->directories($path) as $directory) {
         $this->loadFilesRecursively($directory);
     }
 }
开发者ID:quarkcms,项目名称:connector,代码行数:11,代码来源:ModelLoader.php

示例9: bladeDirective

 public function bladeDirective($name, $class, $method)
 {
     $this->getBlade()->directive($name, function ($expression) use($class, $method) {
         // for Laravel 5.2 and lower
         $expression = isset($expression) ? $expression : '()';
         if (Str::startsWith($expression, '(') && Str::endsWith($expression, ')')) {
             $expression = mb_substr($expression, 1, -1, 'UTF-8');
         }
         return "<?=app({$class}::class)->{$method}({$expression});?>";
     });
 }
开发者ID:jeroennoten,项目名称:laravel-package-helper,代码行数:11,代码来源:BladeDirective.php

示例10: isAcademicEmail

 private static function isAcademicEmail($mail)
 {
     //TODO add academic domains
     $acdomains = array('auth.gr');
     $email = explode('@', $mail);
     $domain = $email[1];
     if (Str::endsWith($domain, $acdomains)) {
         return true;
     }
     return false;
 }
开发者ID:pkoro,项目名称:webconf-portal,代码行数:11,代码来源:roomController.php

示例11: register

 /**
  * Registers specified class as a validation rule to Laravel Validator
  *
  * @param $className
  */
 public static function register($className)
 {
     $ruleName = Str::snake(class_basename($className));
     if (Str::endsWith($ruleName, self::RULE_NAME_SUFFIX)) {
         $ruleName = substr($ruleName, 0, -strlen(self::RULE_NAME_SUFFIX));
     }
     static::$registry[$ruleName] = $className;
     /** @var Factory $validatorFactory */
     $validatorFactory = Application::getInstance()->make(Factory::class);
     $validatorFactory->extend($ruleName, $className . '@validate');
     $validatorFactory->replacer($ruleName, $className . '@replace');
 }
开发者ID:fhteam,项目名称:laravel-validator,代码行数:17,代码来源:ValidationRuleRegistry.php

示例12: testStringEndsWith

 public function testStringEndsWith()
 {
     $str = 'Laravel is really awesome';
     $result = Str::endsWith($str, 'awesome');
     $this->assertEquals($result, true);
     $str = 'Laravel is really awesome';
     $result = Str::endsWith($str, 'Awesome');
     $this->assertEquals($result, false);
     $str = 'Laravel is really awesome';
     $result = Str::endsWith($str, ['Awesome', 'awesome']);
     $this->assertEquals($result, true);
 }
开发者ID:aapiro,项目名称:laravel-strings-examples,代码行数:12,代码来源:HelpersStringsTest.php

示例13: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $packageName = 'laravel-deploy';
     $basePath = \Config::get("{$packageName}::base-path");
     $appName = \Config::get("{$packageName}::application-name");
     $basePath = \Config::get("{$packageName}::base-path");
     $branch = \Config::get("{$packageName}::branch");
     $gitUrl = \Config::get("{$packageName}::git");
     $ownership = \Config::get("{$packageName}::ownership");
     $remoteEnv = \Config::get("{$packageName}::remote-env", "production");
     if (!$appName) {
         $this->error("Please configure application-name inside configuration file. Use `php artisan config:publish quiborgue/{$packageName}` to create it.");
         return;
     }
     if (!$gitUrl) {
         $this->error("Please configure git inside configuration file. Use `php artisan config:publish quiborgue/{$packageName}` to create it.");
         return;
     }
     $release = Carbon::now()->getTimestamp();
     $appPath = "{$basePath}/{$appName}";
     $releasePath = "{$appPath}/releases/{$release}";
     $writables = array();
     $shareds = array('app/storage/sessions/', 'app/storage/logs/', 'app/database/production.sqlite');
     $commandList = array();
     $commandList[] = "export LARAVEL_ENV={$remoteEnv}";
     $commandList[] = "mkdir -p {$releasePath}";
     $commandList[] = "git clone --depth 1 -b {$branch} \"{$gitUrl}\" {$releasePath}";
     $commandList[] = "cd {$releasePath}";
     $commandList[] = "composer install --no-interaction --no-dev --prefer-dist";
     foreach ($shareds as $shared) {
         $sharedPath = "{$appPath}/shared/{$shared}";
         if (Str::endsWith($shared, "/")) {
             $sharedPath = rtrim($sharedPath, "/");
             $shared = rtrim($shared, "/");
             $commandList[] = "mkdir -p {$sharedPath}";
         } else {
             $sharedDirPath = dirname($sharedPath);
             $commandList[] = "mkdir -p {$sharedDirPath}";
             // $commandList[] = "touch $sharedPath";
         }
         $commandList[] = "rm -rf {$releasePath}/{$shared}";
         $commandList[] = "ln -s {$sharedPath} {$releasePath}/{$shared}";
     }
     foreach ($writables as $writable) {
         $commandList[] = "chmod -R 755 {$releasePath}/{$writable}";
         $commandList[] = "chmod -R g+s {$releasePath}/{$writable}";
         $commandList[] = "chown -R {$ownership} {$releasePath}/{$writable}";
     }
     $commandList[] = "rm -f {$appPath}/current";
     $commandList[] = "ln -s {$releasePath} {$appPath}/current";
     $commandList[] = "php artisan migrate --force";
     $this->runCommandList($commandList);
 }
开发者ID:quiborgue,项目名称:laravel-deploy,代码行数:58,代码来源:DeployCommand.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @param  string $target_field
  * @param  string $source_field
  * @param  string $pattern
  * @return mixed
  */
 public function handle($request, Closure $next, $target_field, $source_field = null, $pattern = '/\\s*([\\t\\v]|\\s*,\\s*)+\\s*/')
 {
     //Commas can’t be used by \Illuminate\Pipeline\Pipeline::parsePipeString
     $pattern = str_replace('COMMA', ',', $pattern);
     if (!Str::startsWith($pattern, '/') or !Str::endsWith($pattern, '/') or $pattern == '/') {
         $pattern = '/' . preg_quote($pattern, '/') . '/';
     }
     if (empty($source_field)) {
         $source_field = $target_field;
     }
     $this->setRequestInput($request, $target_field, preg_split($pattern, $request->input($source_field)));
     return $next($request);
 }
开发者ID:fewagency,项目名称:laravel-reformulator,代码行数:23,代码来源:ExplodeInput.php

示例15: addFolder

 public function addFolder()
 {
     $folder = Input::get('name');
     $path = Input::get('path');
     if (Media::checkPath($path)) {
         if (Str::endsWith($path, "/")) {
             $newFolder = $path . $folder;
         } else {
             $newFolder = $path . "/" . $folder;
         }
         return response()->json(mkdir($newFolder));
     }
     return response()->json(false);
 }
开发者ID:VertexDezign,项目名称:VertexDezign,代码行数:14,代码来源:BackendMediaController.php


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