コード例 #1
0
ファイル: Dispatch.php プロジェクト: packaged/dispatch
 /**
  * Is Dispatch responsible for the incoming request
  *
  * @param Request $request
  *
  * @return bool
  */
 public function isDispatchRequest(Request $request)
 {
     $runOn = $this->_config->getItem('run_on', 'path');
     switch ($runOn) {
         case 'path':
             $match = $this->_config->getItem('run_match', 'res');
             return Strings::startsWith($request->getPathInfo() . '/', "/{$match}/");
         case 'subdomain':
             $matchCfg = $this->_config->getItem('run_match', 'static.,assets.');
             $subDomains = ValueAs::arr($matchCfg, ['static.']);
             return Strings::startsWithAny($request->getHost(), $subDomains);
         case 'domain':
             $matchCfg = $this->_config->getItem('run_match', null);
             $domains = ValueAs::arr($matchCfg, []);
             return Strings::endsWithAny($request->getHttpHost(), $domains, false);
     }
     return false;
 }
コード例 #2
0
 /**
  * Check a string ends with one of the provided needles
  *
  * @param       $haystack
  * @param array $needles
  * @param bool  $case
  *
  * @return bool
  *
  * @deprecated
  */
 function ends_with_any($haystack, array $needles, $case = true)
 {
     return \Packaged\Helpers\Strings::endsWithAny($haystack, $needles, $case);
 }
コード例 #3
0
ファイル: StringsTest.php プロジェクト: PaulAntunes/gclf-paul
 public function testEndsWithAny()
 {
     $this->assertTrue(Strings::endsWithAny("abcdef", ["f", "yx"], true));
     $this->assertTrue(Strings::endsWithAny("aBcdeF", ["x", "eF"], true));
     $this->assertTrue(Strings::endsWithAny("aBcdef", ["c", "eF"], false));
     $this->assertFalse(Strings::endsWithAny("abcdef", ["c", "eF"], true));
     $this->assertFalse(Strings::endsWithAny("aBcdef", ["c", "ab"], false));
 }