startsWith() public method

Returns true if the string begins with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public startsWith ( string $substring, boolean $caseSensitive = true ) : boolean
$substring string The substring to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
return boolean Whether or not $str starts with $substring
コード例 #1
2
ファイル: Stringy.php プロジェクト: docit/support
 /**
  * {@inheritdoc}
  */
 public function startsWith($substring, $caseSensitive = true)
 {
     return (bool) parent::startsWith($substring, $caseSensitive);
 }
コード例 #2
0
ファイル: CheckCommand.php プロジェクト: elazar/climb
 /**
  * Get the required packages.
  *
  * @return array
  */
 private function getPackages()
 {
     $file = getcwd() . '/composer.json';
     if (!file_exists($file)) {
         return [];
     }
     $json = json_decode(file_get_contents($file), true);
     $packages = [];
     if (isset($json['require'])) {
         $packages = array_merge($packages, $json['require']);
     }
     if (isset($json['require-dev'])) {
         $packages = array_merge($packages, $json['require-dev']);
     }
     if (count($packages) <= 0) {
         return [];
     }
     $array = [];
     foreach ($packages as $name => $version) {
         $string = new Stringy($name);
         if ($string->startsWith('php') || $string->startsWith('ext')) {
             continue;
         }
         $array[$name] = $version;
     }
     return $array;
 }