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

Breadcrumb

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

function SpdxLicenses::validate

Parameters

string[]|string $license:

Return value

bool

Throws

\InvalidArgumentException

File

vendor/composer/spdx-licenses/src/SpdxLicenses.php, line 191

Class

SpdxLicenses

Namespace

Composer\Spdx

Code

public function validate($license) {
    if (is_array($license)) {
        $count = count($license);
        if ($count !== count(array_filter($license, 'is_string'))) {
            throw new \InvalidArgumentException('Array of strings expected.');
        }
        $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
    }
    if (!is_string($license)) {
        throw new \InvalidArgumentException(sprintf('Array or String expected, %s given.', gettype($license)));
    }
    return $this->isValidLicenseString($license);
}

API Navigation

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