当前位置: 首页>>代码示例>>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;未经允许,请勿转载。