/** * @test */ public function testSupportsDottedPath() { $provider = new StandardVariableProvider(); $provider->setSource(array('foo' => array('bar' => 'baz'))); $result = $provider->getByPath('foo.bar'); $this->assertEquals('baz', $result); }
/** * Get a variable by dotted path expression, retrieving the * variable from nested arrays/objects one segment at a time. * If the second variable is passed, it is expected to contain * extraction method names (constants from VariableExtractor) * which indicate how each value is extracted. * * @param string $path * @return mixed */ public function getByPath($path, array $accessors = array()) { if ($path === 'random') { return 'random' . sha1(rand(0, 999999999999)); } elseif ($path === 'incrementer') { return ++$this->incrementer; } else { return parent::getByPath($path); } }