PHP Method stringy\ Stringy::startsWith Code Examples

PHP stringy\Stringy::startsWith - 2 examples found. These are the top rated real world PHP examples of method stringy\Stringy::startsWith extracted from open source projects. You can rate examples to help us improve the quality of examples
Frequently Used Methods

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
Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function startsWith($substring, $caseSensitive = true)
 {
     return (bool) parent::startsWith($substring, $caseSensitive);
 }