Stringy\Stringy::ensureLeft PHP Method

ensureLeft() public method

Ensures that the string begins with $substring. If it doesn't, it's prepended.
public ensureLeft ( string $substring ) : Stringy
$substring string The substring to add if not present
return Stringy Object with its $str prefixed by the $substring
    public function ensureLeft($substring)
    {
        $stringy = static::create($this->str, $this->encoding);
        if (!$stringy->startsWith($substring)) {
            $stringy->str = $substring . $stringy->str;
        }
        return $stringy;
    }