예제 #1
0
 public function testStartsWith3()
 {
     $this->assertFalse(Str::startsWith('foo', ''));
 }
예제 #2
0
 /**
  * Determine if a given string starts with a given sub-string.
  *
  * @param  string        $haystack  String we're searching in
  * @param  string|array  $needle    Sub-String we're checking if it's at the start
  *
  * @return bool                     If the sub-string is at the start of the haystack
  */
 function starts_with($haystack, $needle)
 {
     return \Anekdotes\Support\Str::startsWith($haystack, $needle);
 }
예제 #3
0
 /**
  * Format the received value into a valid website.
  *
  * @param string $value The input string to format
  *
  * @return string The formatted value
  */
 public static function website($value)
 {
     if (Str::startsWith($value, 'www')) {
         $value = 'http://' . $value;
     } elseif (Str::startsWith($value, '//')) {
         $value = 'http://' . substr($value, 2, strlen($value) - 2);
     } elseif (!Str::startsWith($value, 'http://')) {
         $value = 'http://' . $value;
     }
     return $value;
 }