You are here

public function PathUtilityBase::__construct in Drupal 7 to 8/9 Module Upgrader 8

Constructs a path utility.

Parameters

mixed $path: The path to wrap, either as a string or an array.

Throws

\InvalidArgumentException

Overrides PathUtilityInterface::__construct

File

src/Utility/Path/PathUtilityBase.php, line 22

Class

PathUtilityBase
Base class for PathUtilityInterface implementations.

Namespace

Drupal\drupalmoduleupgrader\Utility\Path

Code

public function __construct($path) {
  if (is_array($path)) {
    foreach ($path as $component) {
      $this
        ->add($component);
    }
  }
  elseif (is_string($path)) {
    $this
      ->__construct(explode('/', $path));
  }
  else {
    throw new \InvalidArgumentException();
  }
}