public function testStartsWith3() { $this->assertFalse(Str::startsWith('foo', '')); }
/** * 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); }
/** * 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; }