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


PHP Str::startsWith方法代碼示例

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


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

示例1: validAuthenticationResponse

 /**
  * Return the valid authentication response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  mixed  $result
  * @return mixed
  */
 public function validAuthenticationResponse($request, $result)
 {
     if (Str::startsWith($request->channel_name, 'private')) {
         return $this->decodePusherResponse($this->pusher->socket_auth($request->channel_name, $request->socket_id));
     } else {
         return $this->decodePusherResponse($this->pusher->presence_auth($request->channel_name, $request->socket_id, $request->user()->id, $result));
     }
 }
開發者ID:hannesvdvreken,項目名稱:framework,代碼行數:15,代碼來源:PusherBroadcaster.php

示例2: crawlUrl

 /**
  * Crawl and process a single URL.
  * @param $url string
  * @return mixed|null
  */
 protected function crawlUrl($url, $parentUrl = null)
 {
     if (!$url || $this->crawled->search($url) !== false || Str::startsWith($url, "#")) {
         return null;
     }
     $this->log("Crawling URL: " . $url);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     $response = curl_exec($ch);
     $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     $header = $this->parseHeader(substr($response, 0, $headerSize));
     $body = substr($response, $headerSize);
     curl_close($ch);
     $this->crawled->push($url);
     if (!$this->validate($header, $body, $url, $parentUrl)) {
         return null;
     }
     $processed = $this->processHtml($url, HtmlDomParser::str_get_html($body));
     $this->add($processed);
     // Recursively crawl other URLs that were found.
     foreach ($processed['urls'] as $href) {
         $this->crawlUrl($href, $url);
     }
 }
開發者ID:breachofmind,項目名稱:birdmin,代碼行數:32,代碼來源:SitemapGenerator.php

示例3: getType

 /**
  * @return string
  */
 protected function getType()
 {
     if ($this->type) {
         return $this->type;
     }
     return Str::startsWith(\Route::currentRouteName(), 'admin.plugins') ? self::TYPE_PLUGINS : self::TYPE_WIDGETS;
 }
開發者ID:marcmascarell,項目名稱:laravel-artificer,代碼行數:10,代碼來源:ExtensionController.php

示例4: isBootable

 /**
  * Determines if is on adminisBootable.
  *
  * @param $path
  * @param null $routePrefix
  * @return bool
  */
 public function isBootable($path, $routePrefix = null)
 {
     if (App::runningInConsole() || App::runningUnitTests()) {
         return true;
     }
     return $path == $routePrefix || Str::startsWith($path, $routePrefix . '/');
 }
開發者ID:marcmascarell,項目名稱:laravel-artificer,代碼行數:14,代碼來源:ArtificerServiceProvider.php

示例5: autoRoute

 /**
  * Controller Auto-Router
  *
  * @param string $controller eg. 'Admin\\UserController'
  * @param array $request_methods eg. array('get', 'post', 'put', 'delete')
  * @param string $prefix eg. admin.users
  * @param array $disallowed eg. array('private_method that starts with one of request methods)
  * @return Closure
  */
 public static function autoRoute($controller, $request_methods, $disallowed = array(), $prefix = '')
 {
     return function () use($controller, $prefix, $disallowed, $request_methods) {
         //get all defined functions
         $methods = get_class_methods(App::make($controller));
         //laravel methods to disallow by default
         $disallowed_methods = array('getBeforeFilters', 'getAfterFilters', 'getFilterer');
         //build list of functions to not allow
         if (is_array($disallowed)) {
             $disallowed_methods = array_merge($disallowed_methods, $disallowed);
         }
         //if there is a index method then lets just bind it and fill the gap in route_names
         if (in_array('getIndex', $methods)) {
             Lara::fillRouteGaps($prefix, $controller . '@getIndex');
         }
         //over all request methods, get, post, etc
         foreach ($request_methods as $type) {
             //filter functions that starts with request method and not in disallowed list
             $actions = array_filter($methods, function ($action) use($type, $disallowed_methods) {
                 return Str::startsWith($action, $type) && !in_array($action, $disallowed_methods);
             });
             foreach ($actions as $action) {
                 $controller_route = $controller . '@' . $action;
                 // Admin\\Controller@get_login
                 $url = Str::snake(str_replace($type, '', $action));
                 // login; snake_case
                 //double check and dont bind to already bound gaps filled index
                 if (in_array($action, $methods) && $action !== 'getIndex') {
                     $route = str_replace('..', '.', $prefix . '.' . Str::snake($action));
                     Route::$type($url, array('as' => $route, 'uses' => $controller_route));
                 }
             }
         }
     };
 }
開發者ID:gxela,項目名稱:lararoute,代碼行數:44,代碼來源:Lara.php

示例6: isFindable

 /**
  * @author bigsinoos <pcfeeler@gmail.com>
  * Check that if a magic method argument is findable or not
  *
  * @param $method
  * @return bool
  */
 private function isFindable($method)
 {
     if (Str::startsWith($method, 'findBy')) {
         return true;
     }
     return false;
 }
開發者ID:Ajaxman,項目名稱:SaleBoss,代碼行數:14,代碼來源:AbstractRepository.php

示例7: absoluteUrl

 /**
  * Add a root if the URL is relative (helper method of the hasLink function).
  *
  * @return string
  */
 protected function absoluteUrl()
 {
     if (!Str::startsWith($this->url, ['http', 'https'])) {
         return URL::to($this->url);
     }
     return $this->url;
 }
開發者ID:levanigongadze,項目名稱:Labweb,代碼行數:12,代碼來源:HasLink.php

示例8: validateAuthorizationHeader

 /**
  * Validate the requests authorization header for the provider.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  *
  * @return bool
  */
 public function validateAuthorizationHeader(Request $request)
 {
     if (Str::startsWith(strtolower($request->headers->get('shield')), $this->getAuthorizationMethod())) {
         return true;
     }
     throw new BadRequestHttpException();
 }
開發者ID:skimia,項目名稱:api-fusion,代碼行數:16,代碼來源:Sentinel.php

示例9: authenticate

 /**
  * Authenticate the request for channel access.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return void
  */
 public function authenticate(Request $request)
 {
     if (Str::startsWith($request->channel_name, 'presence-') && !$request->user()) {
         abort(403);
     }
     return Broadcast::auth($request);
 }
開發者ID:themsaid,項目名稱:framework,代碼行數:13,代碼來源:BroadcastController.php

示例10: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Check file exists
     if (!File::exists($this->argument('file'))) {
         $this->comment('No coverage file found, skipping.');
         return 0;
     }
     // Open serialised file
     $serialised = File::get($this->argument('file'));
     if (!Str::startsWith($serialised, '<?php')) {
         $coverage = unserialize($serialised);
         // Require PHP object in file
     } else {
         $coverage = (require $this->argument('file'));
     }
     // Check coverage percentage
     $total = $coverage->getReport()->getNumExecutableLines();
     $executed = $coverage->getReport()->getNumExecutedLines();
     $percentage = nf($executed / $total * 100, 2);
     // Compare percentage to threshold
     $threshold = $this->argument('threshold');
     if ($percentage >= $threshold) {
         $this->info("Code Coverage of {$percentage}% is higher than the minimum threshold required {$threshold}%!");
         return;
     }
     // Throw error
     $this->error("Code Coverage of {$percentage}% is below than the minimum threshold required {$threshold}%!");
     return 1;
 }
開發者ID:valorin,項目名稱:vest,代碼行數:34,代碼來源:Coverage.php

示例11: registerDirectives

 private function registerDirectives()
 {
     Blade::directive('allowed', function ($expression) {
         if (Str::startsWith($expression, '(')) {
             $expression = substr($expression, 1, -1);
         }
         return "<?php if (app('rbac')->checkAccess(\\Auth::user(), {$expression})): ?>";
     });
     if (Config::get('rbac.shortDirectives')) {
         foreach (Rbac::getRepository() as $name => $item) {
             $directiveName = $item->type == Item::TYPE_PERMISSION ? 'allowed' : 'is';
             $directiveName .= Str::studly(str_replace('.', ' ', $name));
             Blade::directive($directiveName, function ($expression) use($name) {
                 $expression = trim($expression, '()');
                 if (!empty($expression)) {
                     $expression = ', ' . $expression;
                 }
                 return "<?php if (app('rbac')->checkAccess(\\Auth::user(), '{$name}'{$expression})): ?>";
             });
         }
     }
     Blade::directive('endallowed', function ($expression) {
         return "<?php endif; ?>";
     });
 }
開發者ID:azamath,項目名稱:laravel-rbac,代碼行數:25,代碼來源:RbacServiceProvider.php

示例12: parse

 /**
  * Try to parse the token from the request header.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return null|string
  */
 public function parse(Request $request)
 {
     $header = $request->headers->get($this->header, $this->fromAltHeaders($request));
     if ($header && Str::startsWith(strtolower($header), $this->prefix)) {
         return trim(str_ireplace($this->prefix, '', $header));
     }
 }
開發者ID:a161527,項目名稱:cs319-p2t5,代碼行數:14,代碼來源:AuthHeaders.php

示例13: testMap

 public function testMap()
 {
     $router = new Router(new Dispatcher());
     $mapper = $this->make();
     $mapper->map($router);
     $routes = $router->getRoutes();
     $controllers = $this->getControllers();
     $this->assertGreaterThan(0, $routes->count(), 'Each mapper should define at least one route.');
     /** @var Route $route */
     foreach ($routes as $route) {
         $name = $route->getPath();
         // Check that it has a controller
         if (!array_key_exists('controller', $route->getAction())) {
             $this->fail('Route: ' . $name . ' has an invalid handler.' . ' Only use controller handlers.');
         }
         $parts = explode('@', $route->getAction()['controller']);
         // Check that it is controller@method definition
         if (count($parts) < 2) {
             $this->fail('Route: ' . $name . ' has an invalid handler: ' . $route->getActionName() . '. Only use controller@method handlers.');
         }
         // Check it begins with an HTTP method
         if (!Str::startsWith($parts[1], $this->methods)) {
             $this->fail('Route: ' . $name . ' has an invalid handler name: ' . $route->getActionName() . '. The handler name should begin with an HTTP method.');
         }
         // Make sure the controller is white-listed
         if (!in_array($parts[0], $controllers)) {
             $this->fail('Route: ' . $name . ' has an invalid controller' . '. Make sure the test matches the directory controllers.');
         }
         // Make sure the class method exists
         if (!method_exists($parts[0], $parts[1])) {
             $this->fail('Route: ' . $name . ' has an invalid handler.' . ' Make sure the method exists.');
         }
     }
 }
開發者ID:sellerlabs,項目名稱:illuminated,代碼行數:34,代碼來源:RouteMapperTestCase.php

示例14: registerBladeExtensions

 protected function registerBladeExtensions()
 {
     static $templateStack = [];
     $blade = $this->app['blade.compiler'];
     $blade->directive('beautymail', function ($expression) {
         if (Str::startsWith($expression, '(')) {
             $expression = substr($expression, 1, -1);
         }
         return "<?php echo \$__env->make('beautymail::templates.'.{$expression},  array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
     });
     $blade->directive('startBeautymail', function ($expression) use(&$templateStack) {
         if (Str::startsWith($expression, '(')) {
             $expression = substr($expression, 1, -1);
         }
         $matcher = preg_match('#^\'([^\']+)\'(.*)$#', $expression, $matches);
         $templateName = $matches[1];
         $args = $matches[2];
         $templateStack[] = $templateName;
         return "<?php echo \$__env->make('beautymail::templates.{$templateName}Start' {$args},  array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
     });
     $blade->directive('endBeautymail', function ($args) use(&$templateStack) {
         if (Str::startsWith($args, '(')) {
             $args = substr($args, 1, -1);
         }
         $templateName = array_pop($templateStack);
         return "<?php echo \$__env->make('beautymail::templates.{$templateName}End' {$args}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
     });
 }
開發者ID:serpentblade,項目名稱:Beautymail,代碼行數:28,代碼來源:BeautymailServiceProvider.php

示例15: addRootToRelativeUrl

 /**
  * Add a root if the URL is relative (helper method of the hasLink function).
  *
  * @param  string  $url
  * @return string
  */
 protected function addRootToRelativeUrl($url)
 {
     if (!Str::startsWith($url, ['http', 'https'])) {
         return $this->app->make('url')->to($url);
     }
     return $url;
 }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:13,代碼來源:InteractsWithPages.php


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