Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InitCommand.php

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\Command

Code

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>');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal