/** * Match a datestring part * * @param string $value * @param array $patterns * @return boolean */ protected function matchPart($value, array $patterns) { foreach ($patterns as $key => $pattern) { if (preg_match($pattern, $value) === 1) { $this->messenger->add(new StringType($key)); return true; } } return false; }
/** * getMessages interface for Zend\Validator\ValidatorInterface * * @return array */ public function getMessages() { return array_map(function (StringType $msg) { return $msg(); }, $this->messenger->get()); }
public function testYouCanTestIfTheMessengerHasAMessage() { $this->sut->add(new StringType('foo')); $this->assertTrue($this->sut->has(new StringType('foo'))); $this->assertFalse($this->sut->has(new StringType('bar'))); }