/** * {@inheritdoc} * @return string * @throws \InvalidArgumentException */ public function evaluate(array $data) { if (!isset($data['path'])) { throw new \InvalidArgumentException('URL path is missing.'); } $urlPath = $data['path']; $urlParams = $this->paramsInterpreter->evaluate($data); return $this->urlResolver->getUrl($urlPath, $urlParams); }
/** * {@inheritdoc} * @throws \InvalidArgumentException */ public function evaluate(array $data) { if (!isset($data['helper']) || substr_count($data['helper'], '::') != 1) { throw new \InvalidArgumentException('Helper method name in format "\\Class\\Name::methodName" is expected.'); } $helperMethod = $data['helper']; list($helperClass, $methodName) = explode('::', $helperMethod, 2); if (!method_exists($helperClass, $methodName)) { throw new \InvalidArgumentException("Helper method '{$helperMethod}' does not exist."); } $methodParams = $this->paramsInterpreter->evaluate($data); $methodParams = array_values($methodParams); // Use positional argument binding instead of named binding $helperInstance = $this->objectManager->get($helperClass); return call_user_func_array(array($helperInstance, $methodName), $methodParams); }
/** * @dataProvider evaluateWrongParamDataProvider */ public function testEvaluateWrongParam($input, $expectedExceptionMessage) { $this->setExpectedException('\\InvalidArgumentException', $expectedExceptionMessage); $this->_model->evaluate($input); }