0 follower

Final Class Yiisoft\Files\PathMatcher\CompositeMatcher

InheritanceYiisoft\Files\PathMatcher\CompositeMatcher
ImplementsYiisoft\Files\PathMatcher\PathMatcherInterface

Composite matcher allows combining several matchers.

Public Methods

Hide inherited methods

Method Description Defined By
all() Get an instance of composite matcher that gives a match only if all of sub-matchers match. Yiisoft\Files\PathMatcher\CompositeMatcher
any() Get an instance of composite matcher that gives a match if any of sub-matchers match. Yiisoft\Files\PathMatcher\CompositeMatcher
match() Yiisoft\Files\PathMatcher\CompositeMatcher

Method Details

Hide inherited methods

all() public static method

Get an instance of composite matcher that gives a match only if all of sub-matchers match.

public static self all ( Yiisoft\Files\PathMatcher\PathMatcherInterface $matchers )
$matchers Yiisoft\Files\PathMatcher\PathMatcherInterface

Matchers to check.

                public static function all(PathMatcherInterface ...$matchers): self
{
    return new self(false, ...$matchers);
}

            
any() public static method

Get an instance of composite matcher that gives a match if any of sub-matchers match.

public static self any ( Yiisoft\Files\PathMatcher\PathMatcherInterface $matchers )
$matchers Yiisoft\Files\PathMatcher\PathMatcherInterface

Matchers to check.

                public static function any(PathMatcherInterface ...$matchers): self
{
    return new self(true, ...$matchers);
}

            
match() public method

public boolean|null match ( string $path )
$path string

                public function match(string $path): ?bool
{
    $allNulls = true;
    foreach ($this->matchers as $matcher) {
        $match = $matcher->match($path);
        if ($match === null) {
            continue;
        }
        $allNulls = false;
        if ($this->matchAny && $match) {
            return true;
        }
        if (!$this->matchAny && !$match) {
            return false;
        }
    }
    return $allNulls ? null : !$this->matchAny;
}