You are here

public static function FileValidator::normaliseExtensions in Mini site 8

Normalise extensions to convert them to array.

Parameters

string $extensions: String of space and/or comma separated list of extensions.

Return value

array Extension list convert to an array.

2 calls to FileValidator::normaliseExtensions()
ArchiveValidator::validate in src/ArchiveValidator.php
Validate files.
FileValidatorTest::testNormaliseExtensions in tests/src/Unit/FileValidatorTest.php
Test normaliseExtensions() method.

File

src/FileValidator.php, line 81

Class

FileValidator
Class FileValidator.

Namespace

Drupal\minisite

Code

public static function normaliseExtensions($extensions) {
  if (is_array($extensions)) {
    return $extensions;
  }
  $extensions = str_replace([
    ', ',
    ',',
    ' ',
  ], ' ', $extensions);
  $extensions = str_replace(' ', ', ', $extensions);
  return array_values(array_filter(explode(', ', $extensions)));
}