* @return $isset Whether the given configuration key is set
* @throws InvalidArgumentException If $configKey is empty
*/
- public function isConfigurationEntrySet (string $configKey) {
+ public function isConfigurationEntrySet (string $configKey): bool {
// Is it null?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
* @throws InvalidArgumentException If $configKey is empty
* @throws NoConfigEntryException If a configuration element was not found
*/
- public function getConfigEntry (string $configKey) {
+ public function getConfigEntry (string $configKey): mixed {
// Is it null?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
* @throws InvalidArgumentException If $configKey is empty
* @throws InvalidArgumentException If $configValue has an unsupported variable type
*/
- public final function setConfigEntry (string $configKey, $configValue) {
+ public final function setConfigEntry (string $configKey, mixed $configValue): void {
// Is a valid configuration key key provided?
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s,configValue[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey, gettype($configValue));
if (empty($configKey)) {
* @throws InvalidArgumentException If $configKey is empty
* @throws NoConfigEntryException If a configuration element was not found
*/
- public final function unsetConfigEntry (string $configKey) {
+ public final function unsetConfigEntry (string $configKey): void {
// Validate parameters
//* NOISY-DEBUG: */ printf('[%s:%d]: configKey=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $configKey);
if (empty($configKey)) {
* @throws InvalidArgumentException If a parameter is invalid
* @throws UnexpectedValueException If a returned value is of an unexpected type or value
*/
- public function isEnabled (string $keyPart) {
+ public function isEnabled (string $keyPart): bool {
// Validate parameters
//* NOISY-DEBUG: */ printf('[%s:%d]: keyPart=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $keyPart);
if (empty($keyPart)) {
* @param $objectInstance An instance of a FrameworkInterface object
* @return $equals Whether both objects equals
*/
- public function equals (FrameworkInterface $objectInstance) {
+ public function equals (FrameworkInterface $objectInstance): bool {
// Now test it
$equals = ((
$this->__toString() === $objectInstance->__toString()
* @param $callbackInstance An instance of a FrameworkInterface class
* @return void
*/
- public function setCallbackInstance (FrameworkInterface $callbackInstance) {
+ public function setCallbackInstance (FrameworkInterface $callbackInstance): void {
$this->callbackInstance = $callbackInstance;
}
* @return $fieldValue Field value from the user
* @throws NullPointerException If the result instance is null
*/
- public final function getField (string $fieldName) {
+ public final function getField (string $fieldName): mixed {
// The super interface "FrameworkInterface" requires this
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $isSet Whether the given field name is set
* @throws NullPointerException If the result instance is null
*/
- public function isFieldSet (string $fieldName) {
+ public function isFieldSet (string $fieldName): bool {
// The super interface "FrameworkInterface" requires this
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class ???!!! extends Base!!! implements CompileableTemplate {
+class ???!!! extends Base!!! implements !!! {
/**
* Protected constructor
*
* @param $appInstance A manageable application
* @return $///Instance An instance of this !!! class
*/
- public final static function create???!!! (ManageableApplication $appInstance) {
+ public final static function create???!!! (ManageableApplication $appInstance): !!! {
// Get a new instance
$///Instance = new ???!!!();
* @param $className Name of the class
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
}
* @param $innerTemplateInstance A CompileableXmlTemplate instance
* @return $templateInstance An instance of TemplateEngine
*/
- public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance) {
+ public static final function createXmlRewriterTemplateDecorator (CompileableXmlTemplate $innerTemplateInstance): CompileableXmlTemplate {
// Get a new instance
$templateInstance = new XmlRewriterTemplateDecorator();
* @param $add Whether add this group
* @return void
*/
- public function setVariableGroup (string $groupName, bool $add = true) {
+ public function setVariableGroup (string $groupName, bool $add = true): void {
// Call the inner class' method
$this->getTemplateInstance()->setVariableGroup($groupName, $add);
}
* @param $value Value to store in variable
* @return void
*/
- public function addGroupVariable (string $variableName, $value) {
+ public function addGroupVariable (string $variableName, mixed $value): void {
// Call the inner class' method
$this->getTemplateInstance()->addGroupVariable($variableName, $value);
}
*
* @return $templateBasePath The relative base path for all templates
*/
- public final function getTemplateBasePath () {
+ public final function getTemplateBasePath (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getTemplateBasePath();
}
*
* @return $templateBasePath The relative base path for all templates
*/
- public final function getGenericBasePath () {
+ public final function getGenericBasePath (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getGenericBasePath();
}
*
* @return $templateExtension The file extension for all uncompiled templates
*/
- public final function getRawTemplateExtension () {
+ public final function getRawTemplateExtension (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getRawTemplateExtension();
}
* @param $variableGroup Variable group to check
* @return $varStack Found variable group
*/
- public function getVarStack (string $variableGroup) {
+ public function getVarStack (string $variableGroup): array {
// Call the inner class' method
return $this->getTemplateInstance()->getVarStack($variableGroup);
}
*
* @return $codeExtension The file extension for all code templates
*/
- public final function getCodeTemplateExtension () {
+ public final function getCodeTemplateExtension (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getCodeTemplateExtension();
}
*
* @return $templateType The current template's type
*/
- public final function getTemplateType () {
+ public final function getTemplateType (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getTemplateType();
}
* @param $value The value we want to store in the variable
* @return void
*/
- public function assignVariable (string $variableName, $value) {
+ public function assignVariable (string $variableName, mixed $value): void {
// Call the inner class' method
$this->getTemplateInstance()->assignVariable($variableName, $value);
}
* @param $variableGroup Name of variable group (default: 'general')
* @return void
*/
- public function removeVariable (string $variableName, string $variableGroup = 'general') {
+ public function removeVariable (string $variableName, string $variableGroup = 'general'): void {
// Call the inner class' method
$this->getTemplateInstance()->removeVariable($variableName, $variableGroup);
}
* 'html' by default
* @return void
*/
- public function loadHtmlTemplate (string $template) {
+ public function loadHtmlTemplate (string $template): void {
// Call the inner class' method
$this->getTemplateInstance()->loadHtmlTemplate($template);
}
* @param $variableName The configuration variable we want to assign
* @return void
*/
- public function assignConfigVariable (string $variableName) {
+ public function assignConfigVariable (string $variableName): void {
// Call the inner class' method
$this->getTemplateInstance()->assignConfigVariable($variableName);
}
* located in 'code' by default
* @return void
*/
- public function loadCodeTemplate (string $template) {
+ public function loadCodeTemplate (string $template): void {
// Call the inner class' method
$this->getTemplateInstance()->loadCodeTemplate($template);
}
* located in "html" by default
* @return void
*/
- public function loadEmailTemplate ($template) {
+ public function loadEmailTemplate (string $template): void {
// Call the inner class' method
$this->getTemplateInstance()->loadEmailTemplate($template);
}
*
* @return void
*/
- public function compileConfigInVariables () {
+ public function compileConfigInVariables (): void {
// Call the inner class' method
$this->getTemplateInstance()->compileConfigInVariables();
}
*
* @return void
*/
- public function compileVariables () {
+ public function compileVariables (): void {
// Call the inner class' method
$this->getTemplateInstance()->compileVariables();
}
*
* @return void
*/
- public function compileTemplate () {
+ public function compileTemplate (): void {
// Call the inner class' method
$this->getTemplateInstance()->compileTemplate();
}
* @param $variableName Name of the variable we want to assign
* @return void
*/
- public function assignTemplateWithVariable (string $templateName, string $variableName) {
+ public function assignTemplateWithVariable (string $templateName, string $variableName): void {
// Call the inner class' method
$this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName);
}
* @param $responseInstance An instance of a Responseable class
* @return void
*/
- public function transferToResponse (Responseable $responseInstance) {
+ public function transferToResponse (Responseable $responseInstance): void {
// Call the inner class' method
$this->getTemplateInstance()->transportToResponse($responseInstance);
}
*
* @return void
*/
- public function assignApplicationData () {
+ public function assignApplicationData (): void {
// Call the inner class' method
$this->getTemplateInstance()->assignApplicationData();
}
* @param $setMatchAsCode Sets $match if readVariable() returns empty result
* @return $rawCode Compile code with inserted variable value
*/
- public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) {
+ public function compileRawCode (string $rawCode, bool $setMatchAsCode = false): string {
return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode);
}
*
* @return $variableGroups All variable groups
*/
- public final function getVariableGroups () {
+ public final function getVariableGroups (): array {
// Call the inner class' method
return $this->getTemplateInstance()->getVariableGroups();
}
*
* @return $rawTemplateData The raw data from the template
*/
- public function getRawTemplateData () {
+ public function getRawTemplateData (): string {
// Call the inner class' method
return $this->getTemplateInstance()->getRawTemplateData();
}
* @param $newName New name of variable
* @return void
*/
- public function renameVariable (string $oldName, string $newName) {
+ public function renameVariable (string $oldName, string $newName): void {
// Call the inner class' method
$this->getTemplateInstance()->renameVariable($oldName, $newName);
}
*
* @return $streamInstance An instance of this node class
*/
- public final static function create???Stream (Requestable $requestInstance) {
+ public final static function create???Stream (Requestable $requestInstance): Stream {
// Get a new instance
$streamInstance = new ???Stream();
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData ($data) {
+ public function streamData ($data): mixed {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+ throw new UnsupportedOperationException([$this, __FUNCTION__], self::EXCEPTION_UNSPPORTED_OPERATION);
}
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-abstract class BaseStream extends BaseFrameworkSystem {
+abstract class BaseStream extends BaseFrameworkSystem implements Stream {
/**
* Protected constructor
*
*
* @return $streamInstance An instance of this node class
*/
- public static final function createNullCryptoStream () {
+ public static final function createNullCryptoStream (): EncryptableStream {
// Get a new instance
$streamInstance = new NullCryptoStream();
* @param $key Ignored
* @return $encrypted Encrypted string
*/
- public function encryptStream (string $str, string $key = NULL) {
+ public function encryptStream (string $str, string $key = NULL): string {
// Return it
return $str;
}
* @param $key Ignored
* @return $str The unencrypted string
*/
- public function decryptStream (string $encrypted, string $key = NULL) {
+ public function decryptStream (string $encrypted, string $key = NULL): string {
// Return it
return $encrypted;
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
- public function streamData (string $data) {
+ public function streamData (string $data): mixed {
self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $rngInstance An RNG instance
* @return $streamInstance An instance of this node class
*/
- public static final function createOpenSslStream (RandomNumberGenerator $rngInstance) {
+ public static final function createOpenSslStream (RandomNumberGenerator $rngInstance): EncryptableStream {
// Get a new instance
$streamInstance = new OpenSslStream();
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- public function encryptStream (string $str, string $key = NULL) {
+ public function encryptStream (string $str, string $key = NULL): string {
// @TODO unfinished
return $str;
* @param $key Optional key, if none provided, a random key will be generated
* @return $str The unencrypted string
*/
- public function decryptStream (string $encrypted, string $key = NULL) {
+ public function decryptStream (string $encrypted, string $key = NULL): string {
// @TODO unfinished
return $encrypted;
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
- public function streamData (string $data) {
+ public function streamData (string $data): mixed {
self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $streamInstance An instance of this node class
*/
- public final static function create???InputStream () {
+ public final static function create???InputStream (): InputStream {
// Get a new instance
$streamInstance = new ???InputStream();
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData ($data) {
+ public function streamData ($data): mixed {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $streamInstance An instance of this node class
*/
- public final static function create???OutputStream () {
+ public final static function create???OutputStream (): OutputStream {
// Get a new instance
$streamInstance = new ???OutputStream();
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData ($data) {
+ public function streamData ($data): mixed {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
+use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Response\Responseable;
* @param $variableGroup Optional variable group to look in
* @return $index false means not found, >=0 means found on a specific index
*/
- private function getVariableIndex (string $variableName, string $variableGroup = NULL) {
+ private function getVariableIndex (string $variableName, string $variableGroup = NULL): int {
// Replace all dashes to underscores to match variables with configuration entries
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,variableGroup[%s]=%s - CALLED!', $variableName, gettype($variableGroup), $variableGroup));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
// First everything is not found
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
- $found = false;
+ $found = -1;
// If the stack is NULL, use the current group
if (is_null($variableGroup)) {
* @return $isSet Whether the given variable group is set
* @throws InvalidArgumentException If the variable name is left empty
*/
- protected final function isVarStackSet (string $variableGroup) {
+ protected final function isVarStackSet (string $variableGroup): bool {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s - CALLED!', $variableGroup));
if (empty($variableGroup)) {
* @return $varStack Found variable group
* @throws InvalidArgumentException If the variable name is left empty
*/
- public final function getVarStack (string $variableGroup) {
+ public final function getVarStack (string $variableGroup): array {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s - CALLED!', $variableGroup));
if (empty($variableGroup)) {
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- protected final function setVarStack (string $variableGroup, array $varStack) {
+ protected final function setVarStack (string $variableGroup, array $varStack): void {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,varStack()=%d - CALLED!', $variableGroup, count($varStack)));
if (empty($variableGroup)) {
*
* @param $variableName The variable we are looking for
* @param $variableGroup Optional variable group to look in
- * @return $content Content of the variable or null if not found
+ * @return $value Value of the variable or null if not found
* @throws InvalidArgumentException If the variable name is left empty
*/
- protected function readVariable (string $variableName, string $variableGroup = NULL) {
+ protected function readVariable (string $variableName, string $variableGroup = NULL): mixed {
// Check parameters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,variableGroup[%s]=%s - CALLED!', $variableName, gettype($variableGroup), $variableGroup));
if (empty($variableName)) {
// First everything is not found
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-TEMPLATE: variableName=%s', $variableName));
- $content = NULL;
+ $value = NULL;
// If the stack is NULL, use the current group
if (is_null($variableGroup)) {
if ($found !== false) {
// Read it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: Invoking this->getVariableValue(%s,%s) ...', $variableGroup, $found));
- $content = $this->getVariableValue($variableGroup, $found);
+ $value = $this->getVariableValue($variableGroup, $found);
}
- // Return the current position
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: content()=%d - EXIT!', strlen($content)));
- return $content;
+ // Return variable's value
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: value[]=%s - EXIT!', gettype($value)));
+ return $value;
}
/**
* @param $value Value we want to store in the variable
* @return void
*/
- private function addVariable (string $variableName, $value) {
+ private function addVariable (string $variableName, mixed $value): void {
// Set general variable group
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$this->setVariableGroup('general');
*
* @return $result Whether array of found variables or empty array
*/
- private function readCurrentGroup () {
+ private function readCurrentGroup (): array {
// Default is not found
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-TEMPLATE: CALLED!');
$result = [];
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function setVariableGroup (string $groupName, bool $add = true) {
+ public function setVariableGroup (string $groupName, bool $add = true): void {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: groupName=%s,add=%d - CALLED!', $groupName, intval($add)));
if (empty($groupName)) {
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function addGroupVariable (string $variableName, $value) {
+ public function addGroupVariable (string $variableName, mixed $value): void {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
if (empty($variableName)) {
* @param $index Index in variable array
* @return $value Value to set
*/
- private function getVariableValue (string $variableGroup, int $index) {
+ private function getVariableValue (string $variableGroup, int $index): mixed {
// Return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,index[]=%d - CALLED!', $variableGroup, $index));
$value = $this->varStack[$variableGroup][$index]['value'];
* @param $value The value we want to store in the variable
* @return void
*/
- private function modifyVariable (string $variableName, $value) {
+ private function modifyVariable (string $variableName, mixed $value): void {
// Replace all dashes to underscores to match variables with configuration entries
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
* @param $value Value to set
* @return void
*/
- private function setVariableValue (string $variableGroup, int $index, $value) {
+ private function setVariableValue (string $variableGroup, int $index, mixed $value): void {
// Set variable
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,index[]=%d,value[]=%s - CALLED!', $variableGroup, $index, gettype($value)));
$this->varStack[$variableGroup][$index]['value'] = $value;
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- protected function setVariable (string $variableGroup, string $variableName, $value) {
+ protected function setVariable (string $variableGroup, string $variableName, mixed $value): void {
// Check parameters
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableGroup=%s,variableName=%s,value[]=%s - CALLED!', $variableGroup, $variableName, gettype($value)));
if (empty($variableGroup)) {
* @param $value Value to set
* @return $varData Variable data array
*/
- private function generateVariableArray (string $variableName, $value) {
+ private function generateVariableArray (string $variableName, mixed $value): array {
// Replace all dashes to underscores to match variables with configuration entries
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,value[]=%s - CALLED!', $variableName, gettype($value)));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
* @param $templateType The current template's type
* @return void
*/
- protected final function setTemplateType (string $templateType) {
+ protected final function setTemplateType (string $templateType): void {
$this->templateType = $templateType;
}
*
* @return $templateType The current template's type
*/
- public final function getTemplateType () {
+ public final function getTemplateType (): string {
return $this->templateType;
}
* @param $template The last loaded template
* @return void
*/
- private function setLastTemplate (SplFileInfo $fileInstance) {
+ private function setLastTemplate (SplFileInfo $fileInstance): void {
$this->lastTemplate = $fileInstance;
}
*
* @return $template The last loaded template
*/
- private function getLastTemplate () {
+ private function getLastTemplate (): SplFileInfo {
return $this->lastTemplate;
}
* @param $templateBasePath The relative base path for all templates
* @return void
*/
- protected final function setTemplateBasePath (string $templateBasePath) {
+ protected final function setTemplateBasePath (string $templateBasePath): void {
// And set it
$this->templateBasePath = $templateBasePath;
}
*
* @return $templateBasePath The relative base path for all templates
*/
- public final function getTemplateBasePath () {
+ public final function getTemplateBasePath (): string {
// And set it
return $this->templateBasePath;
}
*
* @return $templateBasePath The relative base path for all templates
*/
- public final function getGenericBasePath () {
+ public final function getGenericBasePath (): string {
// And set it
return $this->genericBasePath;
}
* templates
* @return void
*/
- protected final function setRawTemplateExtension (string $templateExtension) {
+ protected final function setRawTemplateExtension (string $templateExtension): void {
// And set it
$this->templateExtension = $templateExtension;
}
* templates
* @return void
*/
- protected final function setCodeTemplateExtension (string $codeExtension) {
+ protected final function setCodeTemplateExtension (string $codeExtension): void {
// And set it
$this->codeExtension = $codeExtension;
}
* @return $templateExtension The file extension for all uncompiled
* templates
*/
- public final function getRawTemplateExtension () {
+ public final function getRawTemplateExtension (): string {
// And set it
return $this->templateExtension;
}
* @return $codeExtension The file extension for all code-
* templates
*/
- public final function getCodeTemplateExtension () {
+ public final function getCodeTemplateExtension (): string {
// And set it
return $this->codeExtension;
}
* templates
* @return void
*/
- protected final function setCompileOutputPath (string $compileOutputPath) {
+ protected final function setCompileOutputPath (string $compileOutputPath): void {
// And set it
$this->compileOutputPath = $compileOutputPath;
}
* @throws InvalidArgumentException If the variable name is left empty
* @throws BadMethodCallException If this method was called but combination of variableGroup/index isn't found
*/
- protected final function unsetVariableStackOffset (int $index, string $variableGroup = NULL) {
+ protected final function unsetVariableStackOffset (int $index, string $variableGroup = NULL): void {
// Check variables
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: index=%d,variableGroup[%s]=%s - CALLED!', $index, gettype($variableGroup), $variableGroup));
if ($index < 0) {
* @param $rawTemplateData The raw data from the template
* @return void
*/
- protected final function setRawTemplateData (string $rawTemplateData) {
+ protected final function setRawTemplateData (string $rawTemplateData): void {
// And store it in this class
$this->rawTemplateData = $rawTemplateData;
}
*
* @return $rawTemplateData The raw data from the template
*/
- public final function getRawTemplateData () {
+ public final function getRawTemplateData (): string {
return $this->rawTemplateData;
}
* @param $compiledData Compiled template data
* @return void
*/
- private function setCompiledData (string $compiledData) {
+ private function setCompiledData (string $compiledData): void {
// And store it in this class
$this->compiledData = $compiledData;
}
*
* @return $compiledData Compiled template data
*/
- public final function getCompiledData () {
+ public final function getCompiledData (): string {
return $this->compiledData;
}
* @throws InvalidArgumentException If the variable name is left empty
* @throws FileNotFoundException If the template was not found
*/
- protected function loadTemplate (string $templateName, string $extOther = '') {
+ protected function loadTemplate (string $templateName, string $extOther = ''): void {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateName=%s,extOther=%s - CALLED!', $templateName, $extOther));
if (empty($templateName)) {
* @param $fileInstance An instance of a SplFileInfo class
* @return void
*/
- private function loadRawTemplateData (SplFileInfo $fileInstance) {
+ private function loadRawTemplateData (SplFileInfo $fileInstance): void {
// Load the raw template
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: fileInstance=%s - CALLED!', $fileInstance->__toString()));
$rawTemplateData = $this->getFileIoInstance()->loadFileContents($fileInstance);
* @param $configKey Possible configuration key
* @return void
*/
- private function assignTemplateVariable (string $variableName, string $configKey = '') {
+ private function assignTemplateVariable (string $variableName, string $configKey = ''): void {
// Replace all dashes to underscores to match variables with configuration entries
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: variableName=%s,configKey=%s - CALLED!', $variableName, $configKey));
$variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
* @param $rawData The raw template data we shall analyze
* @return void
*/
- private function extractVariablesFromRawData (string $rawData) {
+ private function extractVariablesFromRawData (string $rawData): void {
// Search for variables
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: rawData(%d)=%s - CALLED!', strlen($rawData), $rawData));
preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches);
* [2] => Array - An array with right part of a match including ':'
* [3] => Array - An array with right part of a match excluding ':'
*/
- private function analyzeTemplate (array $templateMatches) {
+ private function analyzeTemplate (array $templateMatches): void {
// Backup raw template data
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateMatches()=%d', count($templateMatches)));
$backup = $this->getRawTemplateData();
* @param $template The template's name
* @return void
*/
- private function compileCode (string $code, string $template) {
+ private function compileCode (string $code, string $template): void {
// Is this template already compiled?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: code=%s,template=%s - CALLED!', $code, $template));
if (in_array($template, $this->compiledTemplates)) {
* @param $templateMatches See method analyzeTemplate()
* @return void
*/
- private function insertAllTemplates (array $templateMatches) {
+ private function insertAllTemplates (array $templateMatches): void {
// Run through all loaded codes
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-TEMPLATE: templateMatches()=%d', count($templateMatches)));
foreach ($this->loadedRawData as $template => $code) {
*
* @return void
*/
- private function loadExtraRawTemplates () {
+ private function loadExtraRawTemplates (): void {
// Are there some raw templates we need to load?
if (count($this->rawTemplates) > 0) {
// Try to load all raw templates
* @return void
* @todo Unfinished work or don't die here.
*/
- private function assignAllVariables (array $varMatches) {
+ private function assignAllVariables (array $varMatches): void {
// Search for all variables
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:varMatches()=' . count($varMatches));
foreach ($varMatches[1] as $key => $var) {
* @param $templateMatches See method analyzeTemplate() for details
* @return void
*/
- private function compileRawTemplateData (array $templateMatches) {
+ private function compileRawTemplateData (array $templateMatches): void {
// Are some code-templates found which we need to compile?
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE:loadedRawData()= ' .count($this->loadedRawData));
if (count($this->loadedRawData) > 0) {
*
* @return void
*/
- private function insertRawTemplates () {
+ private function insertRawTemplates (): void {
// Load all templates
foreach ($this->rawTemplates as $template => $content) {
// Set the template as a variable with the content
*
* @return void
*/
- private function finalizeVariableCompilation () {
+ private function finalizeVariableCompilation (): void {
// Get the content
$content = $this->getRawTemplateData();
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: content before=' . strlen($content) . ' (' . md5($content) . ')');
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function loadHtmlTemplate (string $template) {
+ public function loadHtmlTemplate (string $template): void {
// Validate parameter
if (empty($template)) {
// Throw an exception
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public final function assignVariable (string $variableName, $value) {
+ public final function assignVariable (string $variableName, mixed $value): void {
// Validate parameter
if (empty($variableName)) {
// Throw an exception
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public final function removeVariable (string $variableName, string $variableGroup = 'general') {
+ public final function removeVariable (string $variableName, string $variableGroup = 'general'): void {
// Validate parameter
if (empty($variableName)) {
// Throw an exception
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function assignTemplateWithVariable (string $templateName, string $variableName) {
+ public function assignTemplateWithVariable (string $templateName, string $variableName): void {
// Validate parameter
if (empty($templateName)) {
// Throw an exception
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function assignConfigVariable (string $variableName) {
+ public function assignConfigVariable (string $variableName): void {
// Validate parameter
if (empty($variableName)) {
// Throw an exception
* @param $variables An array with variables to be assigned
* @return void
*/
- public function assignMultipleVariables (array $variables) {
+ public function assignMultipleVariables (array $variables): void {
// "Inject" all
foreach ($variables as $name => $value) {
// Set variable with name for 'config' group
*
* @return void
*/
- public function assignApplicationData () {
+ public function assignApplicationData (): void {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function loadCodeTemplate (string $template) {
+ public function loadCodeTemplate (string $template): void {
// Validate parameter
if (empty($template)) {
// Throw an exception
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function loadEmailTemplate (string $template) {
+ public function loadEmailTemplate (string $template): void {
// Validate parameter
if (empty($template)) {
// Throw an exception
*
* @return void
*/
- public final function compileConfigInVariables () {
+ public final function compileConfigInVariables (): void {
// Do we have the stack?
if (!$this->isVarStackSet('general')) {
// Abort here silently
* @return void
* @todo Make this code some nicer...
*/
- public final function compileVariables () {
+ public final function compileVariables (): void {
// Initialize the $content array
$validVar = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('tpl_valid_var');
$dummy = [];
* @throws InvalidArrayCountException If an unexpected array
* count has been found
*/
- public function compileTemplate () {
+ public function compileTemplate (): void {
// Get code type to make things shorter
$codeType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('code_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_template_type');
* Loads a given view helper (by name)
*
* @param $helperName The helper's name
- * @return void
+ * @return $helperInstance An instance of a Helper class
* @throws InvalidArgumentException If the variable name is left empty
*/
- protected function loadViewHelper (string $helperName) {
+ protected function loadViewHelper (string $helperName): HelpableTemplate {
// Validate parameter
if (empty($helperName)) {
// Throw an exception
// Is this view helper loaded?
if (!isset($this->helpers[$helperName])) {
- // Create a class name
- $className = StringUtils::convertToClassName($helperName) . 'ViewHelper';
-
- // Generate new instance
- $this->helpers[$helperName] = ObjectFactory::createObjectByName($className);
+ // Generate new helper instance
+ $this->helpers[$helperName] = ObjectFactory::createObjectByName(StringUtils::convertToClassName($helperName) . 'ViewHelper');
}
// Return the requested instance
* @param $responseInstance An instance of a Responseable class
* @return void
*/
- public function transferToResponse (Responseable $responseInstance) {
+ public function transferToResponse (Responseable $responseInstance): void {
// Get the content and set it in response class
$responseInstance->writeToBody($this->getCompiledData());
}
* @return $rawCode Compile code with inserted variable value
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function compileRawCode (string $rawCode, bool $setMatchAsCode = false) {
+ public function compileRawCode (string $rawCode, bool $setMatchAsCode = false): string {
// Validate parameter
if (empty($rawCode)) {
// Throw an exception
*
* @return $variableGroups All variable groups
*/
- public final function getVariableGroups () {
+ public final function getVariableGroups (): array {
return $this->variableGroups;
}
* @return void
* @throws InvalidArgumentException If the variable name is left empty
*/
- public function renameVariable (string $oldName, string $newName) {
+ public function renameVariable (string $oldName, string $newName): void {
// Validate parameter
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-TEMPLATE: oldName=' . $oldName . ', newName=' . $newName);
if (empty($oldName)) {
* @throws BasePathReadProtectedException If $templateBasePath is
* read-protected
*/
- public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) {
+ public static final function createMenuTemplateEngine (RenderableMenu $menuInstance): CompileableTemplate {
// Get a new instance
$templateInstance = new MenuTemplateEngine();
* @param $menuInstance A RenderableMenu instance
* @return void
*/
- protected final function setMenuInstance (RenderableMenu $menuInstance) {
+ protected final function setMenuInstance (RenderableMenu $menuInstance): void {
$this->menuInstance = $menuInstance;
}
*
* @return $menuInstance A RenderableMenu instance
*/
- private function getMenuInstance () {
+ private function getMenuInstance (): RenderableMenu {
return $this->menuInstance;
}
* located in 'menu' by default
* @return void
*/
- public function loadMenuTemplate (string $template) {
+ public function loadMenuTemplate (string $template): void {
// Set template type
$this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_type'));
*
* @return $currMainNode Current main node
*/
- public final function getCurrMainNode () {
+ public final function getCurrMainNode (): string {
return $this->curr['main_node'];
}
* @param $element Element name to set as current main node
* @return $currMainNode Current main node
*/
- private function setCurrMainNode (string $element) {
+ private function setCurrMainNode (string $element): void {
$this->curr['main_node'] = $element;
}
*
* @return $mainNodes Array with valid main node names
*/
- public final function getMainNodes () {
+ public final function getMainNodes (): array {
return $this->mainNodes;
}
*
* @return $subNodes Array with valid sub node names
*/
- public final function getSubNodes () {
+ public final function getSubNodes (): array {
return $this->subNodes;
}
* @param $templateDependency A template to load to satisfy dependencies
* @return void
*/
- private function startEntryList () {
+ private function startEntryList (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'entry-list');
}
*
* @return void
*/
- private function startBlockHeader () {
+ private function startBlockHeader (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'block-header');
}
*
* @return void
*/
- private function startBlockFooter () {
+ private function startBlockFooter (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'block-footer');
}
*
* @return void
*/
- private function startBlockList () {
+ private function startBlockList (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'block-list');
}
*
* @return void
*/
- private function startBlock () {
+ private function startBlock (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'block');
}
*
* @return void
*/
- private function startTitle () {
+ private function startTitle (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'title');
}
*
* @return void
*/
- private function startTitleId () {
+ private function startTitleId (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'title-id');
}
*
* @return void
*/
- private function startTitleClass () {
+ private function startTitleClass (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'title-class');
}
*
* @return void
*/
- private function startTitleText () {
+ private function startTitleText (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'title-text');
}
*
* @return void
*/
- private function startEntry () {
+ private function startEntry (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'entry');
}
*
* @return void
*/
- private function startEntryId () {
+ private function startEntryId (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'entry-id');
}
*
* @return void
*/
- private function startAnchor () {
+ private function startAnchor (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'anchor');
}
*
* @return void
*/
- private function startAnchorId () {
+ private function startAnchorId (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'anchor-id');
}
*
* @return void
*/
- private function startAnchorText () {
+ private function startAnchorText (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'anchor-text');
}
*
* @return void
*/
- private function startAnchorTitle () {
+ private function startAnchorTitle (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'anchor-title');
}
*
* @return void
*/
- private function startAnchorHref () {
+ private function startAnchorHref (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'anchor-href');
}
*
* @return void
*/
- private function startFooterId () {
+ private function startFooterId (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'footer-id');
}
*
* @return void
*/
- private function startFooterClass () {
+ private function startFooterClass (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'footer-class');
}
*
* @return void
*/
- private function startFooterText () {
+ private function startFooterText (): void {
// Push the node name on the stacker
$this->getStackInstance()->pushNamed('current_node', 'footer-text');
}
*
* @return void
*/
- private function finishTitle () {
+ private function finishTitle (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishTitleId () {
+ private function finishTitleId (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishTitleClass () {
+ private function finishTitleClass (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishTitleText () {
+ private function finishTitleText (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishFooterText () {
+ private function finishFooterText (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishFooterClass () {
+ private function finishFooterClass (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishFooterId () {
+ private function finishFooterId (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishAnchorHref () {
+ private function finishAnchorHref (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishAnchorTitle () {
+ private function finishAnchorTitle (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishAnchorText () {
+ private function finishAnchorText (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishAnchorId () {
+ private function finishAnchorId (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishAnchor () {
+ private function finishAnchor (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishEntryId () {
+ private function finishEntryId (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishEntry () {
+ private function finishEntry (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
*
* @return void
*/
- private function finishBlock () {
+ private function finishBlock (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
*
* @return void
*/
- private function finishBlockList () {
+ private function finishBlockList (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishEntryList () {
+ private function finishEntryList (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishBlockHeader () {
+ private function finishBlockHeader (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishBlockFooter () {
+ private function finishBlockFooter (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function finishMenu () {
+ private function finishMenu (): void {
// Pop the last entry
$this->getStackInstance()->popNamed('current_node');
}
*
* @return void
*/
- private function renderMenuEntry () {
+ private function renderMenuEntry (): void {
// Load menu entry template
$this->getTemplateInstance()->loadCodeTemplate('menu_entry');
*
* @return void
*/
- private function renderMenuBlock () {
+ private function renderMenuBlock (): void {
// Init block content
$blockContent = implode('', $this->menuEntries);
*
* @return $menuContent Returned menu content
*/
- public function getMenuContent () {
+ public function getMenuContent (): string {
// Implode menuBlocks
$menuContent = implode('', $this->menuBlocks);
* @return $mappedArray An array with mapped values
* @throws InvalidArgumentException If a aparameter is not valid
*/
- public static function mapNumericKeysToAssociative (array $numericArray, array $mapping) {
+ public static function mapNumericKeysToAssociative (array $numericArray, array $mapping): array {
// Validate parameters
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('ARRAY-UTILS: numericArray()=%d,mapping()=%d - CALLED!', count($numericArray), count($mapping)));
if (count($numericArray) == 0) {
/**
* Since PHP doesn't have static initializers, this method needs to be
* invoked by each public method here.
+ *
+ * @return void
*/
- private static function staticInitializer () {
+ private static function staticInitializer (): void {
// Is $hashFunction set?
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPRO-UTILS: self::hashFunction[]=%s - CALLED!', gettype(self::$hashFunction)));
if (empty(self::$hashFunction)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws LogicException If proper extension hash is not loaded
*/
- public static final function hash (string $str) {
+ public static final function hash (string $str): string {
// Validate parameter/mhash extension
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('CRYPTO-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
*
* @return $length Length of hash() output
*/
- public static final function getHashLength () {
+ public static final function getHashLength (): int {
// Invoke static initializer
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('CRYPRO-UTILS: Invoking self::staticInitializer() ... - CALLED!');
self::staticInitializer();
* @return $localized Localized value
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static function doFilterFormatNumber (float $value) {
+ public static function doFilterFormatNumber (float $value): string {
// Check value
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: value=%s - CALLED!', $value));
if ($value < 0) {
* @return $readable A readable timestamp
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static function doFilterFormatTimestamp (string $timestamp = NULL) {
+ public static function doFilterFormatTimestamp (string $timestamp = NULL): string {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: timestamp[%s]=%s - CALLED!', gettype($timestamp), $timestamp));
if (empty($timestamp)) {
* @return $formatted The (hopefully) secured numbered value
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- public static function bigintval (string $num, bool $castValue = true, bool $assertMismatch = false) {
+ public static function bigintval (string $num, bool $castValue = true, bool $assertMismatch = false): mixed {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('NUMBER-UTILS: num=%s,castValue=%d,assertMismatch=%d - CALLED!', $num, intval($castValue), intval($assertMismatch)));
if ($num === '') {
* @throws NullPointerException If $str is null
* @throws InvalidArgumentException If $str is empty
*/
- public static function convertDashesToUnderscores (string $str) {
+ public static function convertDashesToUnderscores (string $str): string {
// Validate parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
* @return $encoded Encoded data
* @throws InvalidArgumentException If $rawData has a non-serializable data type
*/
- public static function encodeData ($rawData) {
+ public static function encodeData (mixed $rawData): string {
// Make sure no objects or resources pass through
//* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: rawData[]=%s - CALLED!', gettype($rawData)));
if (is_object($rawData) || is_resource($rawData)) {
* @return $className Generated class name
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static final function convertToClassName (string $str) {
+ public static final function convertToClassName (string $str): string {
// Is the parameter valid?
//* N NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
* @return $price The for the current language formated price string
* @throws MissingDecimalsThousandsSeparatorException If decimals or thousands separator is missing
*/
- public static function formatCurrency (float $value, string $currency = '€', int $decNum = 2) {
+ public static function formatCurrency (float $value, string $currency = '€', int $decNum = 2): string {
// Init instance
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: value=%s,currency=%s,decNum=%d - CALLED!', $value, $currency, $decNum));
$dummyInstance = new StringUtils();
* @return $dec Decimal number
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function hex2dec (string $hex) {
+ public static function hex2dec (string $hex): int {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: hex=%s - CALLED!', $hex));
if (empty($hex)) {
// Return the decimal number
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: sign=%s,dec=%s - EXIT!', $sign, $dec));
- return $sign . $dec;
+ return (int) $sign . $dec;
}
/**
* @return $hex Hexadecimal string
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function dec2hex (int $dec, int $maxLength = 0) {
+ public static function dec2hex (int $dec, int $maxLength = 0): string {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d,maxLength=%d - CALLED!', $dec, $maxLength));
if ($dec < 0) {
* @return $dec Decimal number
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function asc2dec (string $asc) {
+ public static function asc2dec (string $asc): int {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: asc=%s - CALLED!', $asc));
if (empty($asc)) {
* @return $asc An ASCII string
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function dec2asc (int $dec) {
+ public static function dec2asc (int $dec): string {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d - CALLED!', $dec));
if ($dec < 0) {
* @return $asc An ASCII string
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function hex2asc (string $hex) {
+ public static function hex2asc (string $hex): string {
// Check for length, it must be devideable by 2
/* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: hex=%s - CALLED!', $hex));
if (empty($hex)) {
* @throws InvalidArgumentException If a paramter is invalid
* @todo Improve documentation
*/
- private static function packString (string $str) {
+ private static function packString (string $str): string {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: str=%s - CALLED!', $str));
if (empty($str)) {
* @return $ret The (hopefully) secured hext-numbered value
* @throws InvalidArgumentException If a paramter is invalid
*/
- public static function hexval (string $num, bool $assertMismatch = false) {
+ public static function hexval (string $num, bool $assertMismatch = false): string {
// Check parameter
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: num=%s,assertMismatch=%d - CALLED!', $num, intval($assertMismatch)));
if (empty($num)) {
* @param $value The value we want to store in the variable
* @return void
*/
- function assignVariable (string $variableName, $value);
+ function assignVariable (string $variableName, mixed $value): void;
/**
* Load a specified HTML template into the engine
* "html" by default
* @return void
*/
- function loadHtmlTemplate (string $template);
+ function loadHtmlTemplate (string $template): void;
/**
* Load a specified code template into the engine for later compilation
* located in "html" by default
* @return void
*/
- function loadCodeTemplate (string $template);
+ function loadCodeTemplate (string $template): void;
/**
* Load a specified email template into the engine for later compilation
* located in "html" by default
* @return void
*/
- function loadEmailTemplate (string $template);
+ function loadEmailTemplate (string $template): void;
/**
* Compile all variables by inserting their respective values
*
* @return void
*/
- function compileVariables ();
+ function compileVariables (): void;
/**
*
* @return void
*/
- function compileTemplate ();
+ function compileTemplate (): void;
/**
* Adds a variable to current group
* @param $value Value to store in variable
* @return void
*/
- function addGroupVariable (string $variableName, $value);
+ function addGroupVariable (string $variableName, $value): void;
/**
* Removes a given variable
* @param $variableGroup Name of variable group (default: 'general')
* @return void
*/
- function removeVariable (string $variableName, string $variableGroup = 'general');
+ function removeVariable (string $variableName, string $variableGroup = 'general'): void;
/**
* Assign a given congfiguration variable with a value
* @param $variableName The configuration variable we want to assign
* @return void
*/
- function assignConfigVariable (string $variableName);
+ function assignConfigVariable (string $variableName): void;
/**
* Compiles configuration place-holders in all variables. This 'walks'
*
* @return void
*/
- function compileConfigInVariables ();
+ function compileConfigInVariables (): void;
/**
* Assigns the last loaded raw template content with a given variable
* @param $variableName Name of the variable we want to assign
* @return void
*/
- function assignTemplateWithVariable (string $templateName, string $variableName);
+ function assignTemplateWithVariable (string $templateName, string $variableName): void;
/**
* Transfers the content of this template engine to a given response instance
* @param $responseInstance An instance of a Responseable class
* @return void
*/
- function transferToResponse (Responseable $responseInstance);
+ function transferToResponse (Responseable $responseInstance): void;
/**
* Assigns all the application data with template variables
*
* @return void
*/
- function assignApplicationData ();
+ function assignApplicationData (): void;
/**
* "Compiles" a variable by replacing {?var?} with it's content
* @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: false)
* @return $rawCode Compile code with inserted variable value
*/
- function compileRawCode (string $rawCode, bool $setMatchAsCode = false);
+ function compileRawCode (string $rawCode, bool $setMatchAsCode = false): string;
/**
* Renames a variable in code and in stack
* @param $newName New name of variable
* @return void
*/
- function renameVariable (string $oldName, string $newName);
+ function renameVariable (string $oldName, string $newName): void;
/**
* Enables or disables language support
* @param $variableGroup Variable group to check
* @return $varStack Found variable group
*/
- function getVarStack (string $variableGroup);
+ function getVarStack (string $variableGroup): array;
/**
* Settter for variable group
* @param $add Whether add this group
* @return void
*/
- function setVariableGroup (string $groupName, bool $add = true);
+ function setVariableGroup (string $groupName, bool $add = true): void;
/**
* Getter for template type
*
* @return $templateType The current template's type
*/
- function getTemplateType ();
+ function getTemplateType (): string;
/**
* Getter for base path
*
* @return $templateBasePath The relative base path for all templates
*/
- function getTemplateBasePath ();
+ function getTemplateBasePath (): string;
/**
* Getter for generic base path
*
* @return $templateBasePath The relative base path for all templates
*/
- function getGenericBasePath ();
+ function getGenericBasePath (): string;
/**
* Getter for template extension
* @return $templateExtension The file extension for all uncompiled
* templates
*/
- function getRawTemplateExtension ();
+ function getRawTemplateExtension (): string;
/**
* Getter for code-template extension
* @return $codeExtension The file extension for all code-
* templates
*/
- function getCodeTemplateExtension ();
+ function getCodeTemplateExtension (): string;
/**
* Getter for raw template data
*
* @return $rawTemplateData The raw data from the template
*/
- function getRawTemplateData ();
+ function getRawTemplateData (): string;
/**
* Assigns a lot variables into the stack of currently loaded template.
* @param $variables An array with variables to be assigned
* @return void
*/
- function assignMultipleVariables (array $variables);
+ function assignMultipleVariables (array $variables): void;
/**
* Getter for variable group array
*
* @return $variableGroups All variable groups
*/
- function getVariableGroups ();
+ function getVariableGroups (): array;
}