Webmozart\Assert\Assert::startsWith PHP Method

startsWith() public static method

public static startsWith ( $value, $prefix, $message = '' )
    public static function startsWith($value, $prefix, $message = '')
    {
        if (0 !== strpos($value, $prefix)) {
            static::reportInvalidArgument(sprintf($message ?: 'Expected a value to start with %2$s. Got: %s', static::valueToString($value), static::valueToString($prefix)));
        }
    }

Usage Example

 /**
  * Return the path with the basePath prefix
  * if it has been set.
  *
  * @param string $path
  *
  * @return string
  */
 protected function resolvePath($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     if ($this->basePath) {
         $path = $this->basePath . $path;
     }
     $path = Path::canonicalize($path);
     return $path;
 }
All Usage Examples Of Webmozart\Assert\Assert::startsWith