*
* @param $timezone The timezone string (e.g. Europe/Berlin)
* @return $success If timezone was accepted
- * @throws NullPointerException If $timezone is NULL
* @throws InvalidArgumentException If $timezone is empty
*/
- public static function setDefaultTimezone ($timezone) {
- // Is it null?
- if (is_null($timezone)) {
- // Throw NPE
- throw new NullPointerException(NULL, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($timezone)) {
- // Is not a string
- throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone)));
- } elseif ((is_string($timezone)) && (empty($timezone))) {
+ public static function setDefaultTimezone (string $timezone) {
+ // Is it set?
+ if (empty($timezone)) {
// Entry is empty
throw new InvalidArgumentException('timezone is empty');
}
// Import framework stuff
use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
-use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\Registerable;
*
* @param $configKey The configuration key we shall check
* @return $isset Whether the given configuration key is set
- * @throws NullPointerException If $configKey is NULL
* @throws InvalidArgumentException If $configKey is empty
*/
- public function isConfigurationEntrySet ($configKey) {
+ public function isConfigurationEntrySet (string $configKey) {
// Is it null?
- if (is_null($configKey)) {
- // Throw NPE
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($configKey)) {
- // Is not a string
- throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif ((is_string($configKey)) && (empty($configKey))) {
+ if (empty($configKey)) {
// Entry is empty
throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
}
*
* @param $configKey The configuration element
* @return $configValue The fetched configuration value
- * @throws NullPointerException If $configKey is NULL
* @throws InvalidArgumentException If $configKey is empty
* @throws NoConfigEntryException If a configuration element was not found
*/
- public function getConfigEntry ($configKey) {
+ public function getConfigEntry (string $configKey) {
// Is it null?
- if (is_null($configKey)) {
- // Throw NPE
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($configKey)) {
- // Is not a string
- throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif ((is_string($configKey)) && (empty($configKey))) {
+ if (empty($configKey)) {
// Entry is empty
throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
}
* @param $configKey The configuration key we want to add/change
* @param $configValue The configuration value we want to set
* @return void
- * @throws NullPointerException If $configKey is NULL
* @throws InvalidArgumentException If $configKey is empty
* @throws InvalidArgumentException If $configValue has an unsupported variable type
*/
- public final function setConfigEntry ($configKey, $configValue) {
+ public final function setConfigEntry (string $configKey, $configValue) {
// Is a valid configuration key key provided?
- if (is_null($configKey)) {
- // Configuration key is null
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($configKey)) {
- // Is not a string
- throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif ((is_string($configKey)) && (empty($configKey))) {
+ if (empty($configKey)) {
// Entry is empty
throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
} elseif ((is_array($configValue)) || (is_object($configValue)) || (is_resource($configValue))) {
*
* @param $configKey Configuration key to unset
* @return void
- * @throws NullPointerException If $configKey is NULL
* @throws InvalidArgumentException If $configKey is empty
* @throws NoConfigEntryException If a configuration element was not found
*/
- public final function unsetConfigEntry ($configKey) {
+ public final function unsetConfigEntry (string $configKey) {
// Validate parameters
- if (is_null($configKey)) {
- // Configuration key is null
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($configKey)) {
- // Entry is empty
- throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif ((is_string($configKey)) && (empty($configKey))) {
+ if (empty($configKey)) {
// Entry is empty
throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
}
unset(self::$config[$configKey]);
}
- /**
- * Getter for field name
- *
- * @param $fieldName Field name which we shall get
- * @return $fieldValue Field value from the user
- * @throws NullPointerException If the result instance is null
- */
- public final function getField ($fieldName) {
- // The super interface "FrameworkInterface" requires this
- throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
- /**
- * Checks if given field is set
- *
- * @param $fieldName Field name to check
- * @return $isSet Whether the given field name is set
- * @throws NullPointerException If the result instance is null
- */
- public function isFieldSet ($fieldName) {
- // The super interface "FrameworkInterface" requires this
- throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
/**
* Generates a code for hashes from this class
*
$this->callbackInstance = $callbackInstance;
}
+ /**
+ * Getter for field name
+ *
+ * @param $fieldName Field name which we shall get
+ * @return $fieldValue Field value from the user
+ * @throws NullPointerException If the result instance is null
+ */
+ public final function getField (string $fieldName) {
+ // The super interface "FrameworkInterface" requires this
+ throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
+ }
+
+ /**
+ * Checks if given field is set
+ *
+ * @param $fieldName Field name to check
+ * @return $isSet Whether the given field name is set
+ * @throws NullPointerException If the result instance is null
+ */
+ public function isFieldSet (string $fieldName) {
+ // The super interface "FrameworkInterface" requires this
+ throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION);
+ }
+
}
* @param $userName The username from request we shall set
* @return void
*/
- public function setUserAuth ($userName) {
+ public function setUserAuth (string $userName) {
FrameworkBootstrap::getResponseInstance()->addCookie('username', $userName);
}
* @param $passHash The hashed password from request we shall set
* @return void
*/
- public function setPasswordAuth ($passHash) {
+ public function setPasswordAuth (string $passHash) {
FrameworkBootstrap::getResponseInstance()->addCookie('u_hash', $passHash);
}
* @param $withFixed Whether to include a fixed salt (not recommended in p2p applications)
* @return $hashed The hashed and salted string
*/
- public function hashString ($str, $oldHash = '', $withFixed = true) {
- // Cast the string
- $str = (string) $str;
-
+ public function hashString (string $str, string $oldHash = '', bool $withFixed = true) {
// Default is the default salt ;-)
$salt = $this->salt;
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- public function encryptString ($str, $key = NULL) {
+ public function encryptString (string $str, string $key = NULL) {
// Encrypt the string through the stream
$encrypted = $this->cryptoStreamInstance->encryptStream($str, $key);
* @param $encrypted Encrypted string
* @return $str The unencrypted string
*/
- public function decryptString ($encrypted) {
+ public function decryptString (string $encrypted) {
// Encrypt the string through the stream
$str = $this->cryptoStreamInstance->decryptStream($encrypted);
* @param $actionName Action name to set
* @return void
*/
- protected final function setActionName ($actionName) {
- $this->actionName = (string) $actionName;
+ protected final function setActionName (string $actionName) {
+ $this->actionName = $actionName;
}
/**
* @param $handlerName Name of this handler
* @return void
*/
- protected final function setHandlerName ($handlerName) {
+ protected final function setHandlerName (string $handlerName) {
$this->handlerName = $handlerName;
}
if (!$this->getListInstance()->getIterator()->valid()) {
// Not valid!
throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID);
- } // END - if
+ }
// Get current task
$currentTask = $this->getListInstance()->getIterator()->current();
// Skip this silently
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']);
return;
- } // END - if
+ }
// Launch the task and mark it as updated
$currentTask['task_started'] = true;
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
- } // END - if
+ }
// Get time difference from interval delay
$diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000;
if ($updateTask === true) {
// Update the task before leaving
$this->updateTask($currentTask);
- } // END - if
+ }
// Skip this silently
return;
- } // END - if
+ }
// Set last activity
$currentTask['task_last_activity'] = $this->getMilliTime();
// Abort here
break;
- } // END - if
- } // END - foreach
+ }
+ }
// Return found name
return $taskName;
* Registers a task with a task handler.
*
* @param $taskName A task name to register the task on
- * @param $taskInstance The instance that should be registered as a task
+ * @param $taskInstance An instance of a Taskable class
* @return void
*/
- public function registerTask ($taskName, Visitable $taskInstance) {
+ public function registerTask (string $taskName, Taskable $taskInstance) {
// Get interval delay
$intervalDelay = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_interval_delay');
$startupDelay = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_startup_delay');
assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($startupDelay > 0)));
// Create the entry
- $taskEntry = array(
+ $taskEntry = [
// Identifier for the generateHash() method
'id' => $taskName,
// Whether the task is started
'task_interval_delay' => $intervalDelay,
// How often should this task run?
'task_max_runs' => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_max_runs'),
- );
+ ];
// Add the entry
$this->getListInstance()->addEntry('tasks', $taskEntry);
if (!$this->getListInstance()->getIterator()->valid()) {
// Rewind to the beginning for next loop
$this->getListInstance()->getIterator()->rewind();
- } // END - if
+ }
// Try to execute the task
$this->executeCurrentTask();
// Advance to next one
$this->getListInstance()->getIterator()->next();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.');
// Remove all tasks
foreach ($tasks as $entry) {
$this->unregisterTask($entry);
- } // END - foreach
+ }
}
}
* @param $imageType Type of the image
* @return void
*/
- protected final function setImageType ($imageType) {
- $this->imageType = (string) $imageType;
+ protected final function setImageType (string $imageType) {
+ $this->imageType = $imageType;
}
/**
* @param $baseImage A base image template
* @return void
*/
- public final function setBaseImage ($baseImage) {
- $this->baseImage = (string) $baseImage;
+ public final function setBaseImage (string $baseImage) {
+ $this->baseImage = $baseImage;
}
/**
* @param $imageName Name of the image
* @return void
*/
- public final function setImageName ($imageName) {
- $this->imageName = (string) $imageName;
+ public final function setImageName (string $imageName) {
+ $this->imageName = $imageName;
}
/**
* @param $width Width of the image
* @return void
*/
- public final function setWidth ($width) {
- $this->width = (int) $width;
+ public final function setWidth (int $width) {
+ $this->width = $width;
}
/**
* @param $height Height of the image
* @return void
*/
- public final function setHeight ($height) {
- $this->height = (int) $height;
+ public final function setHeight (int $height) {
+ $this->height = $height;
}
/**
// Random numbers?
if ($red === 'rand') {
$red = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
if ($green === 'rand') {
$green = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
if ($blue === 'rand') {
$blue = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
$this->backgroundColor['red'] = (int) $red;
$this->backgroundColor['green'] = (int) $green;
// Random numbers?
if ($red === 'rand') {
$red = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
if ($green === 'rand') {
$green = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
if ($blue === 'rand') {
$blue = $this->getRngInstance()->randomNumber(0, 255);
- } // END - if
+ }
$this->foregroundColor['red'] = (int) $red;
$this->foregroundColor['green'] = (int) $green;
// Random font size?
if ($fontSize === 'rand') {
$fontSize = $this->getRngInstance()->randomNumber(4, 9);
- } // END - if
+ }
$this->imageStrings[$this->currString]['size'] = (int) $fontSize;
}
$templateInstance->addGroupVariable('image_y' , $this->getY());
$templateInstance->addGroupVariable('image_size' , $this->getFontSize());
$templateInstance->addGroupVariable('image_string', $this->getImageString());
- } // END - foreach
+ }
// Get the raw content
$imageContent = $templateInstance->getRawTemplateData();
// Replace character
$captchaString = str_replace($search, $replace, $captchaString, $captchaLength);
- } // END - foreach
+ }
// Get crypto instance
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
* @param $newContent New content to add
* @return void
*/
- protected final function addContent ($newContent) {
- $this->content .= (string) trim($newContent) . PHP_EOL;
+ protected final function addContent (string $newContent) {
+ $this->content .= trim($newContent) . PHP_EOL;
}
/**
* @param $content Content to to the base
* @return void
*/
- protected function addHeaderContent ($content) {
+ protected function addHeaderContent (string $content) {
// Add the header content
- $this->groups['header']['content'] = (string) trim($content);
+ $this->groups['header']['content'] = trim($content);
}
/**
* @param $content Content to to the base
* @return void
*/
- protected function addFooterContent ($content) {
+ protected function addFooterContent (string $content) {
// Add the footer content
- $this->groups['footer']['content'] = (string) trim($content);
+ $this->groups['footer']['content'] = trim($content);
}
/**
* @param $newContent New content to add
* @return void
*/
- protected final function addContentToPreviousGroup ($newContent) {
+ protected final function addContentToPreviousGroup (string $newContent) {
// Check for sub/group
if ($this->ifSubGroupOpenedPreviously()) {
// Get sub group id
* @param $fieldName Name of the field to assign
* @return void
*/
- public function assignField ($fieldName) {
+ public function assignField (string $fieldName) {
// Get the value from value instance
$fieldValue = $this->getValueField($fieldName);
* @return void
* @throws HelperGroupAlreadyCreatedException If the group was already created before
*/
- protected function openGroupByIdContent ($groupId, $content, $tag) {
+ protected function openGroupByIdContent (string $groupId, string $content, string $tag) {
//* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
// Is the group already there?
if (isset($this->groups[$groupId])) {
* @return void
* @throws HelperNoPreviousOpenedGroupException If no previously opened group was found
*/
- public function closePreviousGroupByContent ($content = '') {
+ public function closePreviousGroupByContent (string $content = '') {
// Check if any sub group was opened before
if ($this->ifSubGroupOpenedPreviously()) {
// Close it automatically
* @return void
* @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before
*/
- protected function openSubGroupByIdContent ($subGroupId, $content, $tag) {
+ protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) {
//* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
// Is the group already there?
if (isset($this->subGroups[$subGroupId])) {
* @return void
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
*/
- public function closePreviousSubGroupByContent ($content = '') {
+ public function closePreviousSubGroupByContent (string $content = '') {
// Check if any sub group was opened before
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception
* @param $groupId Id of group to check
* @return $isOpened Whether the specified group is open
*/
- protected function ifGroupIsOpened ($groupId) {
+ protected function ifGroupIsOpened (string $groupId) {
// Is the group open?
$isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true));
* @return $fieldValue Value from field
* @throws NullPointerException Thrown if $valueInstance is null
*/
- public function getValueField ($fieldName) {
+ public function getValueField (string $fieldName) {
// Init value
$fieldValue = NULL;
* @param $previousGroupId Id of previously opened group
* @return void
*/
- protected final function setPreviousGroupId ($previousGroupId) {
- $this->previousGroupId = (string) $previousGroupId;
+ protected final function setPreviousGroupId (string $previousGroupId) {
+ $this->previousGroupId = $previousGroupId;
}
/**
* @param $previousSubGroupId Id of previously opened sub group
* @return void
*/
- protected final function setPreviousSubGroupId ($previousSubGroupId) {
- $this->previousSubGroupId = (string) $previousSubGroupId;
+ protected final function setPreviousSubGroupId (string $previousSubGroupId) {
+ $this->previousSubGroupId = $previousSubGroupId;
}
}
* @param $blockName Name of the block we shall generate
* @return void
*/
- protected final function setBlockName ($blockName) {
- $this->blockName = (string) $blockName;
+ protected final function setBlockName (string $blockName) {
+ $this->blockName = $blockName;
}
/**
* @param $withForm Whether include the form tag
* @return $helperInstance A preparedf instance of this helper
*/
- public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, $formId = false, bool $withForm = true) {
+ public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, string $formId = NULL, bool $withForm = true) {
// Get new instance
$helperInstance = new HtmlFormHelper();
$helperInstance->setTemplateInstance($templateInstance);
// Is the form id not set?
- if ($formId === false) {
+ if (is_null($formId)) {
// Use form id from form name
$formId = $formName;
} // END - if
* @throws InvalidFormNameException If the form name is invalid ( = false)
* @todo Add some unique PIN here to bypass problems with some browser and/or extensions
*/
- public function addFormTag ($formName = false, $formId = false) {
+ public function addFormTag (string $formName = NULL, string $formId = NULL) {
// When the form is not yet opened at least form name must be valid
- if (($this->formOpened === false) && ($formName === false)) {
+ if (($this->formOpened === false) && (is_null($formName))) {
// Thrown an exception
throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID);
- } // END - if
+ }
// Close the form is default
$formContent = '</form>';
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputTextField ($fieldName, $fieldValue = '') {
+ public function addInputTextField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @param $fieldName Input field name
* @return void
*/
- public function addInputTextFieldWithDefault ($fieldName) {
+ public function addInputTextFieldWithDefault (string $fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputPasswordField ($fieldName, $fieldValue = '') {
+ public function addInputPasswordField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputHiddenField ($fieldName, $fieldValue = '') {
+ public function addInputHiddenField (string $fieldName, string $fieldValue = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @param $fieldName Input field name
* @return void
*/
- public function addInputHiddenFieldWithDefault ($fieldName) {
+ public function addInputHiddenFieldWithDefault (string $fieldName) {
// Get the value from instance
$fieldValue = $this->getValueField($fieldName);
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
* @param $prefix Prefix for configuration without trailing _
* @return void
*/
- public function addInputHiddenConfiguredField ($fieldName, $prefix) {
+ public function addInputHiddenConfiguredField (string $fieldName, string $prefix) {
// Get the value from instance
$fieldValue = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry("{$prefix}_{$fieldName}");
//* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."<br />\n";
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputCheckboxField ($fieldName, $fieldChecked = true) {
+ public function addInputCheckboxField (string $fieldName, bool $fieldChecked = true) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
} // END - if
// Set whether the check box is checked...
- $checked = ' checked="checked"';
- if ($fieldChecked === false) $checked = ' ';
+ $checked = ($fieldChecked ? ' checked="checked"' : ' ');
// Generate the content
$inputContent = sprintf('<input type="checkbox" name="%s" class="checkbox" id="%s_%s_field" value="1"%s />',
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputResetButton ($buttonText) {
+ public function addInputResetButton (string $buttonText) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputSubmitButton ($buttonText) {
+ public function addInputSubmitButton (string $buttonText) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @throws FormClosedException If no form has been opened before
* @throws InvalidArgumentException If $groupId is not set
*/
- public function addFormGroup ($groupId = '', $groupText = '') {
+ public function addFormGroup (string $groupId = '', string $groupText = '') {
// Is a form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw exception here
* @throws FormFormClosedException If no group has been opened before
* @throws InvalidArgumentException If $subGroupId is not set
*/
- public function addFormSubGroup ($subGroupId = '', $subGroupText = '') {
+ public function addFormSubGroup (string $subGroupId = '', string $subGroupText = '') {
// Is a group opened?
if ($this->ifGroupOpenedPreviously() === false) {
// Throw exception here
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addFieldLabel ($fieldName, $fieldText, $fieldTitle = '') {
+ public function addFieldLabel (string $fieldName, string $fieldText, string $fieldTitle = '') {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addFormNote ($noteId, $formNotes) {
+ public function addFormNote (string $noteId, string $formNotes) {
// Is the form opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @return void
* @throws FormClosedException If the form is not yet opened
*/
- public function addInputSelectField ($selectId, $firstEntry) {
+ public function addInputSelectField (string $selectId, string $firstEntry) {
// Is the form group opened?
if (($this->formOpened === false) && ($this->formEnabled === true)) {
// Throw an exception
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
* @todo Add checking if sub option is already added
*/
- public function addSelectSubOption ($subName, $subValue) {
+ public function addSelectSubOption (string $subName, string $subValue) {
// Is there a sub group (shall be a selection box!)
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
* @todo Add checking if sub option is already added
*/
- public function addSelectOption ($optionName, $optionValue) {
+ public function addSelectOption (string $optionName, string $optionValue) {
// Is there a sub group (shall be a selection box!)
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
* @param $formEnabled Whether form is enabled or disabled
* @return void
*/
- public final function enableForm ($formEnabled = true) {
- $this->formEnabled = (bool) $formEnabled;
+ public final function enableForm (bool $formEnabled = true) {
+ $this->formEnabled = $formEnabled;
}
/**
* @param $formName Name of this form
* @return void
*/
- public final function setFormName ($formName) {
- $this->formName = (string) $formName;
+ public final function setFormName (string $formName) {
+ $this->formName = $formName;
}
/**
* @param $formId Id of this form
* @return void
*/
- public final function setFormId ($formId) {
- $this->formId = (string) $formId;
+ public final function setFormId (string $formId) {
+ $this->formId = $formId;
}
/**
*
* @return $required Whether the specified chat protocol is enabled
*/
- public function ifChatEnabled ($chatProtocol) {
+ public function ifChatEnabled (string $chatProtocol) {
$required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y');
return $required;
}
* @param $extraContent Optional extra HTML content
* @return $linkContent Rendered text link content
*/
- private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') {
+ private function renderLinkContentWithTextExtraContent (string $linkText, string $linkTitle, string $extraContent = '') {
// Construct link content
$linkContent = sprintf('<a href="{?base_url?}/%s%s" title="%s">%s</a>',
$this->getLinkBase(),
* @param $linkName Name of the link we shall generate
* @return void
*/
- protected final function setLinkName ($linkName) {
- $this->linkName = (string) $linkName;
+ protected final function setLinkName (string $linkName) {
+ $this->linkName = $linkName;
}
/**
* @param $linkBase Base of the link we shall generate
* @return void
*/
- protected final function setLinkBase ($linkBase) {
- $this->linkBase = (string) $linkBase;
+ protected final function setLinkBase (string $linkBase) {
+ $this->linkBase = $linkBase;
}
/**
* @param $groupCode Code to open and close groups
* @return void
*/
- public function addLinkGroup ($groupId, $groupText, $groupCode = 'div') {
+ public function addLinkGroup (string $groupId, string $groupText, string $groupCode = 'div') {
// Is a group with that name open?
if ($this->ifGroupOpenedPreviously()) {
// Then close it here
* @return void
* @throws NoGroupOpenedException If no previous group was opened
*/
- public function addLinkNote ($groupId, $groupNote, $groupCode = 'div') {
+ public function addLinkNote (string $groupId, string $groupNote, string $groupCode = 'div') {
// Check if a previous group was opened
if ($this->ifGroupOpenedPreviously() === false) {
// No group was opened before!
* @return void
* @throws NoGroupOpenedException If no previous group was opened
*/
- protected function addActionLink ($linkAction, $linkText, $linkTitle) {
+ protected function addActionLink (string $linkAction, string $linkText, string $linkTitle) {
// Check if a previous group was opened
if ($this->ifGroupOpenedPreviously() === false) {
// No group was opened before!
* @param $languageId Language id string to use
* @return void
*/
- public function addActionLinkById ($linkAction, $languageId) {
+ public function addActionLinkById (string $linkAction, string $languageId) {
// Resolve the language string
$languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text');
* @param $languageId Language id string to use
* @return void
*/
- public function addLinkWithTextById ($languageId) {
+ public function addLinkWithTextById (string $languageId) {
// Resolve the language string
$languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text');
* @param $element Name of the request element we want to check
* @return $isSet Whether the request element is set
*/
- public function isRequestElementSet ($element) {
+ public function isRequestElementSet (string $element) {
// Is this element found?
$isSet = isset($this->requestData[$element]);
* @return $value Value of the found request element or 'null' if the
* element was not found
*/
- public function getRequestElement ($element) {
+ public function getRequestElement (string $element) {
// Initialize value
$value = NULL;
* @param $value Value to set
* @return void
*/
- public function setRequestElement ($element, $value) {
+ public function setRequestElement (string $element, $value) {
$this->requestData[$element] = $value;
}
* @return $headerValue Value of the header or 'null' if not found
* @throws UnsupportedOperationException This method should never be called
*/
- public function getHeaderElement ($headerName) {
+ public function getHeaderElement (string $headerName) {
// Console doesn't have any headers
throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $cookieValue Value of cookie or null if not found
* @throws UnsupportedOperationException This method should never be called
*/
- public final function readCookie ($cookieName) {
+ public final function readCookie (string $cookieName) {
// There are no cookies on console
throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
*/
- public function getHeaderElement ($headerName) {
+ public function getHeaderElement (string $headerName) {
// Default return value on error
$headerValue = NULL;
* @param $cookieName Name of cookie we shall read
* @return $cookieValue Value of cookie or null if not found
*/
- public final function readCookie ($cookieName) {
+ public final function readCookie (string $cookieName) {
// Default is no cookie with that name found
$cookieValue = NULL;
* @param $stateName Name of this state in a printable maner
* @return void
*/
- protected final function setStateName ($stateName) {
+ protected final function setStateName (string $stateName) {
$this->stateName = $stateName;
}
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- public function encryptStream ($str, $key = NULL) {
+ public function encryptStream (string $str, string $key = NULL) {
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MCRYPT-STREAM: key[' . gettype($key) . ']=' . $key);
* @param $key Optional key, if none provided, a random key will be generated
* @return $str The unencrypted string
*/
- public function decryptStream ($encrypted, $key = NULL) {
+ public function decryptStream (string $encrypted, string $key = NULL) {
// Init crypto module
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
* Encrypt the string with fixed salt
*
* @param $str The unencrypted string
- * @param $key Optional key, if none provided, a random key will be generated
+ * @param $key Ignored
* @return $encrypted Encrypted string
*/
- public function encryptStream ($str, $key = NULL) {
- // Just handle it over
- $encrypted = (string) $str;
-
+ public function encryptStream (string $str, string $key = NULL) {
// Return it
- return $encrypted;
+ return $str;
}
/**
* Decrypt the string with fixed salt
*
* @param $encrypted Encrypted string
+ * @param $key Ignored
* @return $str The unencrypted string
*/
- public function decryptStream ($encrypted) {
- // Just handle it over
- $str = (string) $encrypted;
-
+ public function decryptStream (string $encrypted, string $key = NULL) {
// Return it
- return $str;
+ return $encrypted;
}
/**
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- public function encryptStream ($str, $key = NULL) {
+ public function encryptStream (string $str, string $key = NULL) {
// @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 ($encrypted, $key = NULL) {
+ public function decryptStream (string $encrypted, string $key = NULL) {
// @TODO unfinished
return $encrypted;
* @param $imageType Code fragment or direct value holding the image type
* @return void
*/
- private function setImageType ($imageType) {
+ private function setImageType (string $imageType) {
// Set group to general
$this->setVariableGroup('general');
* @return void
* @see ImageTemplateEngine::setImageResolution
*/
- private function setImageImageString ($groupable = 'single') {
+ private function setImageImageString (string $groupable = 'single') {
// Call the image class
$this->getImageInstance()->initImageString($groupable);
* @param $imageName Name of the image
* @return void
*/
- private function setImagePropertyName ($imageName) {
+ private function setImagePropertyName (string $imageName) {
// Call the image class
$this->getImageInstance()->setImageName($imageName);
}
* @param $width Width of the image or variable
* @return void
*/
- private function setImagePropertyWidth ($width) {
+ private function setImagePropertyWidth (int $width) {
// Call the image class
$this->getImageInstance()->setWidth($width);
}
* @param $height Height of the image or variable
* @return void
*/
- private function setImagePropertyHeight ($height) {
+ private function setImagePropertyHeight (int $height) {
// Call the image class
$this->getImageInstance()->setHeight($height);
}
* @param $stringName String name (identifier)
* @return void
*/
- private function setImagePropertyStringName ($stringName) {
+ private function setImagePropertyStringName (string $stringName) {
// Call the image class
$this->getImageInstance()->setStringName($stringName);
}
* @param $fontSize Size of the font
* @return void
*/
- private function setImagePropertyFontSize ($fontSize) {
+ private function setImagePropertyFontSize (int $fontSize) {
// Call the image class
$this->getImageInstance()->setFontSize($fontSize);
}
* @param $imageString Image string to set
* @return void
*/
- private function setImagePropertyText ($imageString) {
+ private function setImagePropertyText (string $imageString) {
// Call the image class
$this->getImageInstance()->setString($imageString);
}
* @param $x X coordinate
* @return void
*/
- private function setImagePropertyX ($x) {
+ private function setImagePropertyX (int $x) {
// Call the image class
$this->getImageInstance()->setX($x);
}
* @param $y Y coordinate
* @return void
*/
- private function setImagePropertyY ($y) {
+ private function setImagePropertyY (int $y) {
// Call the image class
$this->getImageInstance()->setY($y);
}
* located in 'image' by default
* @return void
*/
- public function loadImageTemplate ($template) {
+ public function loadImageTemplate (string $template) {
// Set template type
$this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('image_template_type'));
* @param $senderAddress Sender address to set in email
* @return void
*/
- private function setEmailPropertySenderAddress ($senderAddress) {
+ private function setEmailPropertySenderAddress (string $senderAddress) {
// Set the template variable
$this->assignVariable('sender', $senderAddress);
}
* @param $recipientAddress Recipient address to set in email
* @return void
*/
- private function setEmailPropertyRecipientAddress ($recipientAddress) {
+ private function setEmailPropertyRecipientAddress (string $recipientAddress) {
// Set the template variable
$this->assignVariable('recipient', $recipientAddress);
}
if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
// Did not match!
throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), Parseable::EXCEPTION_XML_NODE_MISMATCH);
- } // END - if
+ }
// Construct method name
$methodName = 'finish' . StringUtils::convertToClassName($nodeName);
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
// Assign the found characters to variable and use the last entry from
// stack as the name
* @param $templateDependency A template to load to satisfy dependencies
* @return void
*/
- private function handleTemplateDependency ($node, $templateDependency) {
+ private function handleTemplateDependency (string $node, string $templateDependency) {
// Is the template dependency set?
if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
// Get a temporay menu template instance
// Save the parsed raw content in our dependency array
$this->dependencyContent[$node] = $templateInstance->getRawTemplateData();
- } // END - if
+ }
}
/**
* @return void
* @todo Add cache creation here
*/
- private function initMenu ($templateDependency = '') {
+ private function initMenu (string $templateDependency = '') {
// Get web template engine
$this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application'))));
if ($variableName == 'anchor-href') {
// Expand variable with URL then
$variableValue = '{?base_url?}/' . $variableValue;
- } // END - if
+ }
// ... into the instance
$this->getTemplateInstance()->assignVariable($variableName, $variableValue);
- } // END - foreach
+ }
// Compile template + variables
$this->getTemplateInstance()->compileTemplate();
// ... into the instance
$this->getTemplateInstance()->assignVariable($variableName, $variableValue);
- } // END - foreach
+ }
// Assign block content
$this->getTemplateInstance()->assignVariable('block_content', $blockContent);
* @param $element Element name to set as current main node
* @return $currMainNode Current main node
*/
- private final function setCurrMainNode ($element) {
- $this->curr['main_node'] = (string) $element;
+ private final function setCurrMainNode (string $element) {
+ $this->curr['main_node'] = $element;
}
/**
* @param $templateDependency A template to load to satisfy dependencies
* @return void
*/
- protected function handleTemplateDependency ($node, $templateDependency) {
+ protected function handleTemplateDependency (string $node, string $templateDependency) {
// Check that the XML node is not empty
assert(!empty($node));
* @return void
* @throws InvalidXmlNodeException If an unknown/invalid XML node name was found
*/
- public final function startElement ($resource, $element, array $attributes) {
+ public final function startElement ($resource, string $element, array $attributes) {
// Initial method name which will never be called...
$methodName = 'init' . StringUtils::convertToClassName($this->xmlTemplateType);
* @return void
* @throws XmlNodeMismatchException If current main node mismatches the closing one
*/
- public final function finishElement ($resource, $nodeName) {
+ public final function finishElement ($resource, string $nodeName) {
// Make all lower-case
$nodeName = strtolower($nodeName);
* @param $code Code number for the exception
* @return void
*/
- public function __construct ($message, int $code) {
+ public function __construct (string $message, int $code) {
// Just call the parent constructor
parent::__construct($message, $code);
}
* @param $withFixed Whether to include a fixed salt (not recommended in p2p applications)
* @return $hashed The hashed and salted string
*/
- function hashString ($str, $oldHash = '', $withFixed = true);
+ function hashString (string $str, string $oldHash = '', bool $withFixed = true);
/**
* Encrypt the string with fixed salt
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- function encryptString ($str, $key = NULL);
+ function encryptString (string $str, string $key = NULL);
/**
* Decrypt the string with fixed salt
* @param $encrypted Encrypted string
* @return $str The unencrypted string
*/
- function decryptString ($encrypted);
+ function decryptString (string $encrypted);
}
* Registers a task with a task handler.
*
* @param $taskName A task name to register the task on
- * @param $taskInstance The instance we should register as a task
+ * @param $taskInstance An instance of a Taskable class
* @return void
*/
- function registerTask ($taskName, Visitable $taskInstance);
+ function registerTask (string $taskName, Taskable $taskInstance);
/**
* Checks whether tasks are left including idle task
* @param $requestKey Key in request class
* @return void
*/
- function encryptPassword ($requestKey);
+ function encryptPassword (string $requestKey);
/**
* Perform things like informing assigned affilates about new registration
* @param $element Name of the request element we want to check
* @return $isSet Whether the request element is set
*/
- function isRequestElementSet ($element);
+ function isRequestElementSet (string $element);
/**
* Getter for request element or 'null' if element was not found
* @return $value Value of the found request element or 'null' if the
* element was not found
*/
- function getRequestElement ($element);
+ function getRequestElement (string $element);
/**
* Setter for request elements
* @param $value Value to set
* @return void
*/
- function setRequestElement ($element, $value);
+ function setRequestElement (string $element, $value);
/**
* Setter for request data array
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- function encryptStream ($str, $key = NULL);
+ function encryptStream (string $str, string $key = NULL);
/**
* Decrypt the string with fixed salt
*
* @param $encrypted Encrypted string
+ * @param $key Optional key, if none provided, a random key will be generated
* @return $str The unencrypted string
*/
- function decryptStream ($encrypted);
+ function decryptStream (string $encrypted, string $key = NULL);
}
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
- /**
- * Tests setting a NULL default timezone
- */
- public function testSettingNullDefaultTimezone () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone(NULL);
- }
-
- /**
- * Tests setting a boolean default timezone
- */
- public function testSettingBooleanDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone(FALSE);
- }
-
- /**
- * Tests setting a decimal default timezone
- */
- public function testSettingDecimalDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone(12345);
- }
-
- /**
- * Tests setting a float default timezone
- */
- public function testSettingFloatDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone(123.45);
- }
-
- /**
- * Tests setting an array default timezone
- */
- public function testSettingArrayDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone(array());
- }
-
- /**
- * Tests setting an object default timezone
- */
- public function testSettingObjectDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone($this);
- }
-
- /**
- * Tests setting a resource default timezone
- */
- public function testSettingResourceDefaultTimezone () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- FrameworkBootstrap::setDefaultTimezone($resource);
- }
-
/**
* Tests setting an empty default timezone
*/
$this->assertEquals($config1, $config2);
}
- /**
- * Tests if a proper exception is thrown when check for a NULL key
- */
- public function testCheckingNullConfigKey () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet(NULL);
- }
-
- /**
- * Tests if a proper exception is thrown when checking a boolean key
- */
- public function testCheckingBooleanConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet(FALSE);
- }
-
/**
* Tests if a proper exception is thrown when checking an empty key
*/
$dummy = self::$configInstance->isConfigurationEntrySet('');
}
- /**
- * Tests if a proper exception is thrown when checking an array key
- */
- public function testCheckingArrayConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet(array());
- }
-
- /**
- * Tests if a proper exception is thrown when checking a decimal key
- */
- public function testCheckingDecimalConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet(12345);
- }
-
- /**
- * Tests if a proper exception is thrown when checking a float key
- */
- public function testCheckingFloatConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet(123.45);
- }
-
- /**
- * Tests if a proper exception is thrown when checking an object key
- */
- public function testCheckingObjectConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet($this);
- }
-
- /**
- * Tests if a proper exception is thrown when checking a resource key
- */
- public function testCheckingResourceConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- $dummy = self::$configInstance->isConfigurationEntrySet($resource);
- }
-
/**
* Tests if checking an existing (well-known) key can be found and returns
* TRUE.
$this->assertFalse(self::$configInstance->isConfigurationEntrySet('__non_existing_key__'));
}
- /**
- * Tests if a proper exception is thrown when getting a NULL key
- */
- public function testGettingNullConfigKey () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry(NULL);
- }
-
- /**
- * Tests if a proper exception is thrown when getting a boolean key
- */
- public function testGettingBooleanConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry(FALSE);
- }
-
/**
* Tests if a proper exception is thrown when getting an empty key
*/
$dummy = self::$configInstance->getConfigEntry('');
}
- /**
- * Tests if a proper exception is thrown when getting a decimal key
- */
- public function testGettingDecimalConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry(12345);
- }
-
- /**
- * Tests if a proper exception is thrown when getting a float key
- */
- public function testGettingFloatConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry(123.45);
- }
-
- /**
- * Tests if a proper exception is thrown when getting an array key
- */
- public function testGettingArrayConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry(array());
- }
-
- /**
- * Tests if a proper exception is thrown when getting an object key
- */
- public function testGettingObjectConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry($this);
- }
-
- /**
- * Tests if a proper exception is thrown when getting a resource key
- */
- public function testGettingResourceConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- $dummy = self::$configInstance->getConfigEntry($resource);
- }
-
/**
* Tests if getting a non-existing key will cause a proper exception been
* thrown.
$this->assertDirectoryIsReadable($value);
}
- /**
- * Tests setting a NULL key (value doesn't matter)
- */
- public function testSettingNullConfigKey () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- self::$configInstance->setConfigEntry(NULL, 'foo');
- }
-
- /**
- * Tests setting a boolean key (value doesn't matter)
- */
- public function testSettingBooleanConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setConfigEntry(FALSE, 'foo');
- }
-
/**
* Tests setting an empty key (value doesn't matter)
*/
self::$configInstance->setConfigEntry('', 'foo');
}
- /**
- * Tests setting a decimal key (value doesn't matter)
- */
- public function testSettingDecimalConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setConfigEntry(12345, 'foo');
- }
-
- /**
- * Tests setting a float key (value doesn't matter)
- */
- public function testSettingFloatConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setConfigEntry(123.45, 'foo');
- }
-
- /**
- * Tests setting an array key (value doesn't matter)
- */
- public function testSettingArrayConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setConfigEntry(array(), 'foo');
- }
-
- /**
- * Tests setting an object key (value doesn't matter)
- */
- public function testSettingObjectConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->setConfigEntry($this, 'foo');
- }
-
- /**
- * Tests setting a resource key (value doesn't matter)
- */
- public function testSettingResourceConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- self::$configInstance->setConfigEntry($resource, 'foo');
- }
-
/**
* Tests setting a valid key but array for value
*/
self::$configInstance->setConfigEntry('foo', $resource);
}
- /**
- * Tests unsetting NULL key
- */
- public function testUnsettingNullConfigKey () {
- // Will throw this exception
- $this->expectException(NullPointerException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry(NULL);
- }
-
- /**
- * Tests unsetting boolean key
- */
- public function testUnsettingBooleanConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry(FALSE);
- }
-
- /**
- * Tests unsetting decimal key
- */
- public function testUnsettingDecimalConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry(12345);
- }
-
- /**
- * Tests unsetting float key
- */
- public function testUnsettingFloatConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry(123.45);
- }
-
- /**
- * Tests unsetting array key
- */
- public function testUnsettingArrayConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry(array());
- }
-
- /**
- * Tests unsetting object key
- */
- public function testUnsettingObjectConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Test it
- self::$configInstance->unsetConfigEntry($this);
- }
-
- /**
- * Tests unsetting resource key
- */
- public function testUnsettingResourceConfigKey () {
- // Will throw this exception
- $this->expectException(InvalidArgumentException::class);
-
- // Init some resource
- $resource = fopen(__FILE__, 'r');
-
- // Test it
- self::$configInstance->unsetConfigEntry($resource);
- }
-
/**
* Tests unsetting an empty key
*/