/** * Validate given path and returns it. * * @param string $path * @return string * @throws InvalidDotNotation When a invalid dot notation path is given. */ protected function validate($path) { if (!preg_match($this->validator, $path)) { throw InvalidDotNotation::forPath($path); } return $path; }
/** * @covers \PhpUtils\Container\Exception\InvalidDotNotation::forPath */ public function testCanConstructForPath() { $exception = InvalidDotNotation::forPath('foo bar'); $this->assertInstanceOf(InvalidDotNotation::class, $exception); $this->assertSame('Invalid dot notation path, got "foo bar".', $exception->getMessage()); }