Dustin Wilson
3 years ago
5 changed files with 19 additions and 47 deletions
@ -1,33 +0,0 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2021 Dustin Wilson et al. |
|||
* See LICENSE and AUTHORS files for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace dW\Highlighter\Scope; |
|||
|
|||
class CompositeMatcher extends Matcher { |
|||
protected Matcher $matcher; |
|||
|
|||
public function __construct(Matcher $left, string $operator, Matcher $right) { |
|||
switch ($operator) { |
|||
case '|': |
|||
$this->matcher = new OrMatcher($left, $right); |
|||
break; |
|||
case '&': |
|||
$this->matcher = new AndMatcher($left, $right); |
|||
break; |
|||
case '-': |
|||
$this->matcher = new AndMatcher($left, new NegateMatcher($right)); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
public function matches(string ...$scopes): bool { |
|||
return $this->matcher->matches(...$scopes); |
|||
} |
|||
|
|||
public function getPrefix(string ...$scopes): string|null|false { |
|||
return $this->matcher->getPrefix(...$scopes); |
|||
} |
|||
} |
Loading…
Reference in new issue