當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Str::contains方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Str::contains方法的典型用法代碼示例。如果您正苦於以下問題:PHP Str::contains方法的具體用法?PHP Str::contains怎麽用?PHP Str::contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Str的用法示例。


在下文中一共展示了Str::contains方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: install

 /**
  * Install the components.
  *
  * @return void
  */
 public function install()
 {
     if (Str::contains(file_get_contents(base_path('.env')), 'AUTHY_SECRET')) {
         return;
     }
     (new Filesystem())->append(base_path('.env'), file_get_contents(SPARK_HEX_STUB_PATH . '/.env'));
 }
開發者ID:peterfox,項目名稱:hexavel-spark,代碼行數:12,代碼來源:InstallEnvironment.php

示例2: rollback

 public function rollback()
 {
     if (Str::contains($this->menuContents, $this->menuTemplate)) {
         file_put_contents($this->path, str_replace($this->menuTemplate, '', $this->menuContents));
         $this->commandData->commandComment('menu deleted');
     }
 }
開發者ID:infyomlabs,項目名稱:laravel-generator,代碼行數:7,代碼來源:MenuGenerator.php

示例3: get

 /**
  * Retorna informações do XML com base no caminho separado por ponto.
  *
  * @param $key
  * @return XMLGet
  */
 public function get($key)
 {
     if (Str::contains($key, '|')) {
         $opcoes = explode('|', $key);
         foreach ($opcoes as $op) {
             $achado = $this->get($op);
             if (!$achado->isNull()) {
                 return $achado;
             }
         }
         return new XMLGet(null);
     }
     $base = $this;
     $niveis = $key == '' ? [] : explode('.', $key);
     foreach ($niveis as $i => $nivel) {
         // Verificar se base eh nula
         if (is_null($base)) {
             return new XMLGet(null);
         }
         $elem = $base->getElementsByTagName($nivel);
         $base = $elem->length > 0 ? $elem->item(0) : null;
     }
     // Retornar o conteúdo do ultimo nível
     if (!is_null($base)) {
         return new XMLGet($base);
     }
     return new XMLGet(null);
 }
開發者ID:phpnfe,項目名稱:tools,代碼行數:34,代碼來源:XML.php

示例4: appendDisqusScript

    /**
     * Append disqus script on the end of the page.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Http\Response $response
     * @return mixed
     */
    protected function appendDisqusScript($request, $response)
    {
        $content = $response->getContent();
        if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
            return;
        }
        $uri = $request->getRequestUri();
        $pageUrl = url($uri);
        $pageId = 'route' . implode('.', explode('/', $uri));
        $username = config('disqus.username');
        $disqusHtml = <<<CDATA
<script>
     var disqus_config = function () {
         this.page.url = '{$pageUrl}';
         this.page.identifier = '{$pageId}';
     };

    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');

        s.src = '//{$username}.disqus.com/embed.js';

        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
        $bodyPosition = strripos($content, '</body>');
        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
        }
        $response->setContent($content);
    }
開發者ID:yajra,項目名稱:laravel-disqus,代碼行數:41,代碼來源:DisqusMiddleware.php

示例5: handle

 /**
  * @param Message $message
  * @return mixed
  */
 public function handle(Message $message)
 {
     if ($message->user->login === \Auth::user()->login) {
         return $message;
     }
     // Personal message
     $isBotMention = $message->hasMention(function (User $user) {
         return $user->login === \Auth::user()->login;
     });
     if ($isBotMention) {
         //$this->ai->handle($message);
     } else {
         // Hello all
         $isHello = Str::contains($message->text_without_special_chars, \Lang::get('personal.hello_query'));
         if ($isHello) {
             $id = array_rand(\Lang::get('personal.hello'));
             $message->italic(\Lang::get('personal.hello.' . $id, ['user' => $message->user->login]));
         }
         // Question
         $isQuestion = Str::contains($message->text_without_special_chars, ['можно задать вопрос', 'хочу задать вопрос']);
         if ($isQuestion) {
             $message->italic(sprintf('@%s, и какой ответ ты ожидаешь услышать?', $message->user->login));
         }
     }
     return $message;
 }
開發者ID:Dualse,項目名稱:GitterBot,代碼行數:30,代碼來源:PersonalAnswersMiddleware.php

示例6: stripProtocol

 /**
  * Strip the protocol from a domain.
  *
  * @param string $domain
  *
  * @return string
  */
 protected function stripProtocol($domain)
 {
     if (Str::contains($domain, '://')) {
         $domain = substr($domain, strpos($domain, '://') + 3);
     }
     return $domain;
 }
開發者ID:JamesGuthrie,項目名稱:api,代碼行數:14,代碼來源:Domain.php

示例7: retrieveByCredentials

 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array  $credentials
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     if (empty($credentials)) {
         return null;
     }
     $index = null;
     $values = null;
     foreach ($credentials as $key => $value) {
         if (!Str::contains($key, 'password')) {
             $index = is_null($index) ? $key : $index . '_' . $key;
             $values = is_null($values) ? [] : $values;
             $values[] = $value;
         }
     }
     if (is_null($index) || is_null($values)) {
         return null;
     }
     $values = count($values) == 1 ? $values[0] : $values;
     $result = $this->createModel()->newQuery()->getQuery()->r()->getAll($values, ['index' => $index])->run();
     $result = $this->hydrate($result);
     if ($result) {
         $result = $result->first();
     }
     return $result;
 }
開發者ID:brunojk,項目名稱:laravel-rethinkdb,代碼行數:31,代碼來源:RethinkUserProvider.php

示例8: view

 /**
  * @param $template
  * @return \Illuminate\Contracts\View\View
  */
 protected function view($template)
 {
     if (Str::contains($template, '::')) {
         return $this->view->make($template);
     } else {
         return $this->view->make('admin::' . $template);
     }
 }
開發者ID:darrengopower,項目名稱:framework,代碼行數:12,代碼來源:AbstractAdminController.php

示例9: isRelationship

 protected function isRelationship(ReflectionMethod $method)
 {
     if ($method->getNumberOfParameters()) {
         return false;
     }
     $source = $this->getMethodSource($method);
     return Str::contains($source, $this->getRelationshipStrings());
 }
開發者ID:quarkcms,項目名稱:connector,代碼行數:8,代碼來源:RelationshipInspector.php

示例10: formatHelperName

 protected function formatHelperName($helper)
 {
     $namespace = $this->app->getNamespace();
     if (!Str::contains($helper, $namespace)) {
         $helper = $namespace . 'Helpers\\' . $helper;
     }
     return $helper;
 }
開發者ID:jenky,項目名稱:laravel-api-starter,代碼行數:8,代碼來源:HelperManager.php

示例11: handle

 public function handle(Request $request, Closure $next)
 {
     $agent = $request->header('User-Agent');
     if ($agent && Str::contains($agent, $this->badUserAgents)) {
         return abort(400);
     }
     return $next($request);
 }
開發者ID:spyc,項目名稱:elearn-foundation,代碼行數:8,代碼來源:BlockUserAgent.php

示例12: setActive

 public static function setActive($path, $active = 'active')
 {
     //funcion para agregar la clase active en el menu del sistema
     if (Str::contains(Request::capture()->path(), 'auth')) {
         return '';
     }
     return Str::contains(Request::capture()->path(), $path) ? $active : '';
 }
開發者ID:diego1q2w,項目名稱:validador,代碼行數:8,代碼來源:general.php

示例13: rollback

 public function rollback()
 {
     if (Str::contains($this->routeContents, $this->routesTemplate)) {
         $this->routeContents = str_replace($this->routesTemplate, '', $this->routeContents);
         file_put_contents($this->path, $this->routeContents);
         $this->commandData->commandComment('scaffold routes deleted');
     }
 }
開發者ID:infyomlabs,項目名稱:laravel-generator,代碼行數:8,代碼來源:RoutesGenerator.php

示例14: processCommand

 /**
  * Apply modifiers to some commands before
  * they're executed
  *
  * @param string $command
  *
  * @return string
  */
 public function processCommand($command)
 {
     // Add environment flag to commands
     $stage = $this->connections->getCurrentConnectionKey()->stage;
     if (Str::contains($command, 'artisan') && $stage) {
         $command .= ' --env="' . $stage . '"';
     }
     return $command;
 }
開發者ID:rocketeers,項目名稱:rocketeer-laravel,代碼行數:17,代碼來源:LaravelStrategy.php

示例15: fire

 /**
  * @param \Notadd\Foundation\Extension\ExtensionManager           $manager
  * @param \Notadd\Foundation\Setting\Contracts\SettingsRepository $settings
  *
  * @return bool
  */
 public function fire(ExtensionManager $manager, SettingsRepository $settings)
 {
     $name = $this->input->getArgument('name');
     $extensions = $manager->getExtensionPaths();
     if (!$extensions->offsetExists($name)) {
         $this->error("Extension {$name} do not exist!");
         return false;
     }
     if (!$this->container->make(SettingsRepository::class)->get('extension.' . $name . '.installed')) {
         $this->error("Extension {$name} does not installed!");
         return false;
     }
     $extension = $extensions->get($name);
     $path = $extension;
     if (Str::contains($path, $manager->getVendorPath())) {
         $this->error("Please update extension {$name} from composer command!");
         return false;
     }
     $extensionFile = new JsonFile($path . DIRECTORY_SEPARATOR . 'composer.json');
     $extension = collect($extensionFile->read());
     if ($extension->has('autoload')) {
         $autoload = collect($extension->get('autoload'));
         $autoload->has('classmap') && collect($autoload->get('classmap'))->each(function ($value) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             if (!in_array($path, $this->backup['autoload']['classmap'])) {
                 $this->backup['autoload']['classmap'][] = $path;
             }
         });
         $autoload->has('files') && collect($autoload->get('files'))->each(function ($value) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value));
             if (!in_array($path, $this->backup['autoload']['files'])) {
                 $this->backup['autoload']['files'][] = $path;
             }
         });
         $autoload->has('psr-0') && collect($autoload->get('psr-0'))->each(function ($value, $key) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-0'][$key] = $path;
         });
         $autoload->has('psr-4') && collect($autoload->get('psr-4'))->each(function ($value, $key) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-4'][$key] = $path;
         });
         $this->json->addProperty('autoload', $this->backup['autoload']);
         $settings->set('extension.' . $name . '.autoload', json_encode($autoload->toArray()));
     }
     if ($extension->has('require')) {
         $require = collect($extension->get('require'));
         $require->each(function ($version, $name) {
             $this->backup['require'][$name] = $version;
         });
         $this->json->addProperty('require', $this->backup['require']);
         $settings->set('extension.' . $name . '.require', json_encode($require->toArray()));
     }
     $this->updateComposer(true);
     $this->info("Extension {$name} is updated!");
     return true;
 }
開發者ID:notadd,項目名稱:framework,代碼行數:63,代碼來源:UpdateCommand.php


注:本文中的Illuminate\Support\Str::contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。