當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。