for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace DependencyAnalyzer\DependencyGraph\FullyQualifiedStructuralElementName;
use DependencyAnalyzer\DependencyGraph\FullyQualifiedStructuralElementName;
class Namespace_ extends Base
{
/**
* @param string $elementName
* @inheritDoc
*/
public function __construct(string $elementName)
if (substr($elementName, -1) !== '\\') {
$elementName .= '\\';
}
parent::__construct($elementName);
public function getType(): string
return FullyQualifiedStructuralElementName::TYPE_NAMESPACE;
public function include(Base $that): bool
if ($this->toString() === '\\') {
// Pattern likely '\\' will match with all className.
return true;
} elseif ($this->isSame($that)) {
} elseif (count($this->getFullyQualifiedNamespaceNameAsArray()) > count($this->getFullyQualifiedNamespaceNameAsArray())) {
return false;
$namesOfThat = $that->getFullyQualifiedNamespaceNameAsArray();
foreach ($this->getFullyQualifiedNamespaceNameAsArray() as $index => $name) {
if (!isset($namesOfThat[$index]) || $namesOfThat[$index] !== $name) {
public function isNamespace(): bool
public function getFullyQualifiedNamespaceNameAsArray(): array
return [];
return explode('\\', trim($this->toString(), '\\'));
public function getFullyQualifiedClassNameAsArray(): ?array
return null;