Neos\Flow\Mvc\Routing\StaticRoutePart::match PHP Метод

match() публичный Метод

This is TRUE if $routePath is not empty and the first part is equal to the Route Part name.
public match ( string &$routePath ) : boolean
$routePath string The request path to be matched - without query parameters, host and fragment.
Результат boolean TRUE if Route Part matched $routePath, otherwise FALSE.
    public function match(&$routePath)
    {
        $this->value = null;
        if ($this->name === null || $this->name === '') {
            return false;
        }
        if ($routePath === '') {
            return false;
        }
        $valueToMatch = substr($routePath, 0, strlen($this->name));
        if ($valueToMatch !== $this->name) {
            return false;
        }
        $shortenedRequestPath = substr($routePath, strlen($valueToMatch));
        $routePath = $shortenedRequestPath !== false ? $shortenedRequestPath : '';
        return true;
    }

Usage Example

 /**
  * @test
  */
 public function matchResetsValueBeforeProcessingTheRoutePath()
 {
     $routePart = new Mvc\Routing\StaticRoutePart();
     $routePart->setName('foo');
     $routeValues = [];
     $routePart->resolve($routeValues);
     $this->assertSame('foo', $routePart->getValue());
     $routePath = 'foo';
     $routePart->match($routePath);
     $this->assertNull($routePart->getValue(), 'Static Route Part must reset their value to NULL.');
 }