/** * mappableIfThen * @param LexiconMethod[] $true * @param LexiconMethod[] $false * @return ObjectInterface * @throws CatchableException */ public function mappableIfThen($true, $false = null) { if ($this->getModel()->getValue()) { $objectInterface = Parameter::parseLexiconParameter($true, true); } else { $objectInterface = Parameter::parseLexiconParameter($false, true); } return $objectInterface; }
/** * addRound * @return Method */ private function addRound() { $method = new Method(); $method->setName('round'); $method->setDescription('Rounds two numbers'); $method->setReturnType(Method::RETURN_DOUBLE); $parameter = new Parameter(); $parameter->setRequired(false); $parameter->setAllowedType(Method::RETURN_DOUBLE); $parameter->setDescription('The Precision to round by'); $method->addParameter($parameter); $method->setHandler([$this, 'mappableRound']); return $method; }
/** * mappableFilter * @param LexiconMethod[] $subParsed * @return array */ public function mappableFilter(array $subParsed) { $outputValue = []; foreach ($this->getModel()->getValue() as $key => $value) { $output = Parameter::parseLexiconParameter($subParsed, false, Root::createObject($value)); if ($output instanceof BooleanInterface) { /** @var BooleanInterface $output */ $output = $output->getValue(); } if ($output) { $outputValue[] = $value; } } return $outputValue; }
/** * addTrim * @return Method */ private function addRightFill() { $method = new Method(); $method->setName('rightFill'); $method->setDescription('This adds characters to the right side of the string'); $method->setReturnType(Method::RETURN_STRING); $parameter = new Parameter(); $parameter->setAllowedType(Method::RETURN_INT); $parameter->setDescription('The length to fill the string to'); $method->addParameter($parameter); $parameter = new Parameter(); $parameter->setRequired(false); $parameter->setAllowedType(Method::RETURN_STRING); $parameter->setDescription('The string to fill it with. Defaults to " "'); $method->addParameter($parameter); $method->setHandler([$this, 'mappableRightFill']); return $method; }