protected function parseAuth($auth)
{
$parts = explode(':', $auth, 2);
if (count($parts) != 2) {
$message = sprintf('Auth "<error>%s</error>" is not valid. The format should be username:password', $auth);
throw new \InvalidArgumentException($message);
}
if (!preg_match('#^[a-zA-Z0-9]{2,}$#', $parts[0])) {
$message = sprintf('The username "<error>%s</error>" for --auth is not valid', $parts[0]);
throw new \InvalidArgumentException($message);
}
$minLength = 6;
if (strlen($parts[1]) < $minLength) {
$message = sprintf('The minimum password length for --auth is %d characters', $minLength);
throw new \InvalidArgumentException($message);
}
return ["username" => $parts[0], "password" => $parts[1]];
}