function InitCommand::parseAuthorString
Return value
array{name: string, email: string|null}
2 calls to InitCommand::parseAuthorString()
- InitCommand::formatAuthors in vendor/
composer/ composer/ src/ Composer/ Command/ InitCommand.php - InitCommand::interact in vendor/
composer/ composer/ src/ Composer/ Command/ InitCommand.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ InitCommand.php, line 474
Class
- InitCommand
- @author Justin Rainbow <justin.rainbow@gmail.com> @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\CommandCode
private function parseAuthorString(string $author) : array {
if (Preg::isMatch('/^(?P<name>[- .,\\p{L}\\p{N}\\p{Mn}\'’"()]+)(?:\\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
if (null !== $match['email'] && !$this->isValidEmail($match['email'])) {
throw new \InvalidArgumentException('Invalid email "' . $match['email'] . '"');
}
return [
'name' => trim($match['name']),
'email' => $match['email'],
];
}
throw new \InvalidArgumentException('Invalid author string. Must be in the formats: ' . 'Jane Doe or John Smith <john@example.com>');
}