You are here

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

Returns a PathUtilityInterface for the parent path.

Return value

static

Throws

\LengthException if the path cannot have a parent (i.e., the path only has one component).

Overrides PathUtilityInterface::getParent

File

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

Class

PathUtilityBase
Base class for PathUtilityInterface implementations.

Namespace

Drupal\drupalmoduleupgrader\Utility\Path

Code

public function getParent() {
  if ($this
    ->count() > 1) {
    return new static($this
      ->slice(0, -1));
  }
  else {
    throw new \LengthException('Cannot get parent a path with one component.');
  }
}