You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
865 B
39 lines
865 B
<?php
|
|
/** @license MIT
|
|
* Copyright 2021 Dustin Wilson et al.
|
|
* See LICENSE file for details */
|
|
|
|
declare(strict_types=1);
|
|
namespace dW\Lit\Scope;
|
|
|
|
class ScopeMatcher extends Matcher {
|
|
protected array $segments;
|
|
|
|
public function __construct(string ...$segments) {
|
|
$this->segments = $segments;
|
|
}
|
|
|
|
public function matches(string $scope): bool {
|
|
$scopeSegments = explode('.', $scope);
|
|
|
|
if (count($this->segments) !== count($scopeSegments)) {
|
|
return false;
|
|
}
|
|
|
|
foreach ($this->segments as $index => $segment) {
|
|
if ($segment === '*') {
|
|
continue;
|
|
}
|
|
|
|
if ($segment !== $scopeSegments[$index]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function getPrefix(string $scope) {
|
|
return null;
|
|
}
|
|
}
|
|
|