Ouzo\Utilities\Strings::prependIfMissing PHP Method

prependIfMissing() public static method

Example: $string = 'Daenerys Targaryen'; $stringWithPrefix = Strings::appendMissingPrefix($string, 'Daenerys '); Result: Daenerys Targaryen
public static prependIfMissing ( string $string, string $prefix ) : string
$string string
$prefix string
return string
    public static function prependIfMissing($string, $prefix)
    {
        if (Strings::startsWith($string, $prefix)) {
            return $string;
        }
        return Strings::appendPrefix($string, $prefix);
    }

Usage Example

Beispiel #1
0
 public function bind($className, $name = '')
 {
     $className = Strings::prependIfMissing($className, '\\');
     $binder = new Binder($className, $name);
     $this->binders[$className . '_' . $name] = $binder;
     return $binder;
 }
All Usage Examples Of Ouzo\Utilities\Strings::prependIfMissing