<?php
namespace App\GenDocument\TextProcessor; class DefaultFunctions extends \Engine\GenDocument\TextProcessor\DefaultFunctions { public function toLetters($lang='', $currency='', $separator='', $currencySubdivision='') { if (!$lang){ $outputLang = 'EN'; } else { $outputLang = $lang; } $class = sprintf('\App\Utils\DigitsToLetters\%s', $outputLang); if (!class_exists($class)) { $class = '\App\Utils\DigitsToLetters\EN'; } if ($currencySubdivision) { $finalSubdivision = $currencySubdivision; } elseif ($currency) { $currDet = \App\Config\Currencies::getInstance()->get($currency); $finalSubdivision = $currDet['subdivisionName']; } else { $finalSubdivision = ''; } $text = $class::create($this->value, $currency, $finalSubdivision, $separator)->getText(); return new self((string)$text); } public function instantiateEntity($objectType){ $className='\Entity\\'.$objectType; if (class_exists($className) && is_subclass_of($className, "\App\Entity\SelectAbstract")) { return new static($className::select($this->value)); } throw new \Exception("Class '{$objectType}' doesn't exist!"); } public function numeralsConvert($format) { return \App\Utils\NumeralsConvert::convert($this->value, $format); } } 