/** * @covers CSanquer\FakeryGenerator\Helper\Converter::convert * @dataProvider providerConvert */ public function testConvert($method, $value, $expected, $delta = null) { if ($delta === null) { $this->assertSame($expected, Converter::convert($method, $value)); } else { $this->assertEquals($expected, Converter::convert($method, $value), 'the converted value is not valid.', $delta); } }
/** * * @param array $availableVariables * @return string */ public function replaceVariable(array $availableVariables) { if ($this->countColumns() > 0) { $result = []; foreach ($this->columns as $column) { $result[$column->getName()] = $column->replaceVariable($availableVariables); } return $result; } $value = preg_replace_callback('/%([a-zA-Z0-9_]+)%/', function ($matches) use($availableVariables) { return isset($availableVariables[$matches[1]]['flat']) ? $availableVariables[$matches[1]]['flat'] : $matches[0]; }, $this->getValue()); return Converter::convert($this->getConvertMethod(), $value); }