/** * Tests formula, knowing it's possible values for correctnes. * * @param array $valueNames If not provided, tries to get current values if they are exists. * @throws InvalidArgumentException * @return boolean */ public function isCorrect(array $valueNames = array()) { $source = $this->getSource(); if (empty($source)) { return true; } $experiment = new WpTesting_Model_Formula(); $experiment->setSource($source); if (empty($valueNames)) { $experiment->addValues($this->substituteValues); } else { foreach (array_unique($valueNames) as $name) { $experiment->addValue($name, 12, 0.34); } } if (empty($experiment->substituteValues)) { throw new InvalidArgumentException('Value names are required when own values are empty'); } try { $substitute = $experiment->substitute(); return !empty($substitute); } catch (PHPParser_Error $e) { return false; } }