startsWith() публичный метод

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
Результат boolean Whether or not $str starts with $substring
Пример #1
1
 /**
  * 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;
 }
Пример #2
1
 /**
  * {@inheritdoc}
  */
 public function startsWith($substring, $caseSensitive = true)
 {
     return (bool) parent::startsWith($substring, $caseSensitive);
 }