public function testCompareMultiple() { $comparator = new Matcher(['id' => '1', 'category' => 'bar']); $this->assertFalse($comparator->match([])); $this->assertFalse($comparator->match(['id' => '1'])); $this->assertFalse($comparator->match(['id' => '1', 'category' => 'bat'])); $this->assertFalse($comparator->match(['category' => 'bar'])); $this->assertTrue($comparator->match(['id' => '1', 'category' => 'bar'])); }
/** * {@inheritdoc} */ public function match($patternOrPatterns, $route = null, $priority = 5) { if (is_array($patternOrPatterns)) { foreach ($patternOrPatterns as $pattern => $route) { $this->match($pattern, $route); } return null; } return $this->parent->match($this->prefix . '/' . $patternOrPatterns, $route, $priority); }
/** * Advances the current position to the next match of a given matcher. * * @param $matcher The matcher * @return The index of the tag which has been found, or false if the end of the souce has been reached */ public function find(Matcher $matcher) { $oldPos = $this->pos; $result = $matcher->match($this->source, $this->pos); if ($this->pos !== $oldPos) { $this->line += substr_count($this->source, "\n", $oldPos, $this->pos - $oldPos); } return $result; }
/** * * @param FixtureData $data * @throws FixtureException */ public function persist(FixtureData $data) { $object = $data->getObject(); $class = get_class($object); foreach ($this->mapping as $mapping) { if (!Matcher::match($class, $mapping['pattern'])) { continue; } return $mapping['persister']->persist($data); } throw new FixtureException(sprintf('not matching for class "%s"', $class)); }
/** * Retrieve files match by user pattern * * @return FileInfo[] */ public function getFiles() { return $this->matcher->match($this->rootDirectory); }