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


PHP Str::is方法代码示例

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


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

示例1: handle

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $roles = $this->file->getRequire(base_path(config('trust.permissions')));
     $this->call('trust:permissions');
     $all = Permission::all(['id', 'slug']);
     $create = 0;
     $update = 0;
     foreach ($roles as $slug => $attributes) {
         $role = $this->findRole($slug);
         if ($role) {
             if ($this->option('force')) {
                 ++$update;
                 $role->update($attributes + compact('slug'));
             }
         } else {
             ++$create;
             $role = Role::create($attributes + compact('slug'));
         }
         $permissions = array_reduce(Arr::get($attributes, 'permissions', []), function (Collection $result, string $name) use($all) {
             if (hash_equals('*', $name)) {
                 return $all->pluck('id');
             }
             if ($all->count() === $result->count()) {
                 return $result;
             }
             $filtered = $all->filter(function (Permission $permission) use($name) {
                 return Str::is($name, $permission->slug);
             })->pluck('id');
             return $result->merge($filtered);
         }, new Collection());
         $role->permissions()->sync($permissions->toArray());
     }
     $total = $create + $update;
     $this->line("Installed {$total} roles. <info>({$create} new roles, {$update} roles synced)</info>");
 }
开发者ID:znck,项目名称:trust,代码行数:40,代码来源:InstallRolesCommand.php

示例2: isActive

 /**
  * {@inheritDoc}
  */
 public function isActive()
 {
     // If URL start with # then it is only client side routing
     if (Str::startsWith($this->getUrl(), '#')) {
         return false;
     }
     return Str::is($this->getUrl(), $this->container->make(Request::class)->url());
 }
开发者ID:vi-kon,项目名称:laravel-menu,代码行数:11,代码来源:Link.php

示例3: scanPath

 public function scanPath($path = '', $mask = null)
 {
     $files = scandir($this->getPath($path));
     return collect($files)->filter(function ($file) use($mask) {
         if (!in_array($file, ['.', '..'])) {
             return $mask ? Str::is($mask, $file) : true;
         }
         return false;
     });
 }
开发者ID:quarkcms,项目名称:connector,代码行数:10,代码来源:ConfigManager.php

示例4: findAvailableHandlers

 /**
  * Find all handlers that are available for the current SlashCommand
  * and have a signature.
  *
  * @return Collection|SignatureHandler[]
  */
 protected function findAvailableHandlers() : Collection
 {
     return collect(config('laravel-slack-slash-command.handlers'))->map(function (string $handlerClassName) {
         return new $handlerClassName($this->request);
     })->filter(function (HandlesSlashCommand $handler) {
         return $handler instanceof SignatureHandler;
     })->filter(function (SignatureHandler $handler) {
         $signatureParts = new SignatureParts($handler->getSignature());
         return Str::is($signatureParts->getSlashCommandName(), $this->request->command);
     });
 }
开发者ID:spatie,项目名称:laravel-slack-slash-command,代码行数:17,代码来源:Help.php

示例5: prepareParams

 protected function prepareParams($params)
 {
     $data = array();
     foreach ($params as $key => $value) {
         if (is_object($value) && Str::is('Illuminate\\*\\Events\\*', get_class($value))) {
             $value = $this->prepareParams(get_object_vars($value));
         }
         $data[$key] = htmlentities($this->exporter->exportValue($value), ENT_QUOTES, 'UTF-8', false);
     }
     return $data;
 }
开发者ID:sethathay,项目名称:PPBakery,代码行数:11,代码来源:EventCollector.php

示例6: testStringIs

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

示例7: verifyUserCanAccessChannel

 /**
  * Authenticate the incoming request for a given channel.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  string  $channel
  * @return mixed
  */
 protected function verifyUserCanAccessChannel($request, $channel)
 {
     foreach ($this->channels as $pattern => $callback) {
         if (!Str::is(preg_replace('/\\{(.*?)\\}/', '*', $pattern), $channel)) {
             continue;
         }
         $parameters = $this->extractAuthParameters($pattern, $channel, $callback);
         if ($result = $callback($request->user(), ...$parameters)) {
             return $this->validAuthenticationResponse($request, $result);
         }
     }
     throw new HttpException(403);
 }
开发者ID:bryanashley,项目名称:framework,代码行数:20,代码来源:Broadcaster.php

示例8: check

 /**
  * Authenticate the incoming request for a given channel.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return mixed
  */
 public function check($request)
 {
     $channel = str_replace(['private-', 'presence-'], '', $request->channel_name);
     foreach ($this->channels as $pattern => $callback) {
         if (!Str::is($pattern, $channel)) {
             continue;
         }
         $parameters = $this->extractAuthParameters($pattern, $channel);
         if ($result = $callback($request->user(), ...$parameters)) {
             return $this->validAuthenticationResponse($request, $result);
         }
     }
     throw new HttpException(403);
 }
开发者ID:mark86092,项目名称:laravel-framework,代码行数:20,代码来源:Broadcaster.php

示例9: getCustomMessageFromTranslator

 /**
  * Get the custom error message from translator.
  *
  * @param  string  $customKey
  * @return string
  */
 protected function getCustomMessageFromTranslator($customKey)
 {
     if (($message = $this->translator->trans($customKey)) !== $customKey) {
         return $message;
     }
     $shortKey = preg_replace('/^lpanel::validation\\.custom\\./', '', $customKey);
     $customMessages = Arr::dot((array) $this->translator->trans('lpanel::validation.custom'));
     foreach ($customMessages as $key => $message) {
         if (Str::contains($key, ['*']) && Str::is($key, $shortKey)) {
             return $message;
         }
     }
     return $customKey;
 }
开发者ID:Viktor-V,项目名称:LPanel,代码行数:20,代码来源:Validator.php

示例10: check

 private function check($source, $ip)
 {
     if (count($source)) {
         if (in_array($ip, $source)) {
             return true;
         }
     }
     foreach ($source as $pattern) {
         if (Str::is($pattern, $ip)) {
             return true;
         }
     }
     return false;
 }
开发者ID:awatbayazidi,项目名称:foundation,代码行数:14,代码来源:Firewall.php

示例11: displayPackages

 private function displayPackages()
 {
     $vendors = $this->templateStorageEngine->getInstalledPackages();
     $displayPackages = [];
     foreach ($vendors as $vendor) {
         foreach ($vendor['packages'] as $package) {
             if ($this->argument('q') !== null) {
                 if (Str::is($this->argument('q'), $package['package']) === false) {
                     continue;
                 }
             }
             $displayPackages[] = [$package['package'], $vendor['vendor'], $package['version'], $package['instance']->getDescription()];
         }
     }
     $this->table(['Package', 'Vendor', 'Version', 'Description'], $displayPackages);
 }
开发者ID:newup,项目名称:core,代码行数:16,代码来源:Search.php

示例12: findAlternativeHandlers

 protected function findAlternativeHandlers(string $command) : Collection
 {
     $alternativeHandlers = collect(config('laravel-slack-slash-command.handlers'))->map(function (string $handlerClassName) {
         return new $handlerClassName($this->request);
     })->filter(function (HandlesSlashCommand $handler) {
         return $handler instanceof SignatureHandler;
     })->filter(function (SignatureHandler $handler) {
         $signatureParts = new SignatureParts($handler->getSignature());
         return Str::is($signatureParts->getSlashCommandName(), $this->request->command);
     });
     if (strpos($command, ':') !== false) {
         $subHandlers = $this->findInNamespace($alternativeHandlers, $command);
         if ($subHandlers->count()) {
             return $subHandlers;
         }
     }
     return $alternativeHandlers->filter(function (SignatureHandler $handler) use($command) {
         return levenshtein($handler->getName(), $command) <= 2;
     });
 }
开发者ID:spatie,项目名称:laravel-slack-slash-command,代码行数:20,代码来源:CatchAll.php

示例13: handle

 public function handle($callback = null)
 {
     if (Arr::get($_POST, 'option') == $this->id) {
         if (!is_null($callback)) {
             call_user_func($callback, $this);
         }
         foreach ($this->items as $item) {
             if ($item->type == "checkbox" && !isset($_POST[$item->id])) {
                 // preset value for checkboxes which are not checked
                 $_POST[$item->id] = "0";
             }
             if (Str::is('*[*]', $item->id)) {
                 continue;
             }
             if ($_POST[$item->id] != option($item->id, null, false)) {
                 Option::set($item->id, $_POST[$item->id]);
             }
         }
         session()->flash($this->id . '.status', 'success');
     }
     return $this;
 }
开发者ID:printempw,项目名称:blessing-skin-server,代码行数:22,代码来源:OptionForm.php

示例14: getOptions

 /**
  * Find the options for the current request, based on the paths/hosts settings.
  *
  * @param Request $request
  *
  * @return array
  */
 protected function getOptions(Request $request)
 {
     $defaults = $this->app['config']->get('df.cors.defaults', []);
     $paths = $this->getPath();
     $uri = $request->getPathInfo() ?: '/';
     $host = $request->getHost();
     foreach ($paths as $pathPattern => $options) {
         //Check for legacy patterns
         if ($request->is($pathPattern) || Str::startsWith($pathPattern, '^') && preg_match('{' . $pathPattern . '}i', $uri)) {
             $options = array_merge($defaults, $options);
             // skip if the host is not matching
             if (isset($options['hosts']) && count($options['hosts']) > 0) {
                 foreach ($options['hosts'] as $hostPattern) {
                     if (Str::is($hostPattern, $host)) {
                         return $options;
                     }
                 }
                 continue;
             }
             return $options;
         }
     }
     return $defaults;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:31,代码来源:DfCorsServiceProvider.php

示例15: hasPermission

 /**
  * Check if the user has a permission.
  *
  * @param int|string $permission
  * @return bool
  */
 public function hasPermission($permission)
 {
     return $this->getPermissions()->contains(function ($key, $value) use($permission) {
         return $permission == $value->id || Str::is($permission, $value->slug);
     });
 }
开发者ID:waylaidwanderer,项目名称:roles,代码行数:12,代码来源:HasRoleAndPermission.php


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