* @deprecated Not fully, as the new Logger facilities are not finished yet.
*/
public final static function createDebugInstance (string $className, int $lineNumber = NULL) {
- // Is the instance set?
- if (!GenericRegistry::getRegistry()->instanceExists('debug')) {
+ // Validate parameter
+ if (empty($className)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "className" is empty');
+ } elseif (!GenericRegistry::getRegistry()->instanceExists('debug')) {
// Init debug instance
$debugInstance = NULL;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
// Import SPL stuff
+use \InvalidArgumentException;
use \SplFileInfo;
/**
* @return $stackInstance An instance of a StackableFile class
*/
public static final function createFileStackInstance (string $prefix, string $stackName) {
+ // Validate parameter
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-FACTORY: prefix=%s,stackName=%s - CALLED!', $prefix, $stackName));
+ if (empty($prefix)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "prefix" is empty');
+ } elseif (empty($stackName)) {
+ // Throw it again
+ throw new InvalidArgumentException('Paramter "stackName" is empty');
+ }
+
// Construct file stack name
$fileInfoInstance = new SplFileInfo(sprintf('%s%s/%s.%s',
FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('root_base_path'),
}
// Return the instance
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-FACTORY: stackInstance=%s - EXIT!', $stackInstance->__toString()));
return $stackInstance;
}
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A factory class for XML template engines. All instances generated by this
* factory does have language support disabled and XML-compacting enabled (to
* @return $templateInstance A template engine instance
*/
public static final function createXmlTemplateEngineInstance (string $configKey) {
+ // Validate parameter
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-TEMPLATE-ENGINE-FACTORY: configKey=%s - CALLED!', $configKey));
+ if (empty($configKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Paramter "configKey" is empty');
+ }
+
// Do we have an instance in the registry?
if (GenericRegistry::getRegistry()->instanceExists($configKey)) {
// Then use this instance
}
// Return the instance
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('XML-TEMPLATE-ENGINE-FACTORY: templateInstance=%s - EXIT!', $templateInstance->__toString()));
return $templateInstance;
}
$seekStatus = $this->seek(0, SEEK_END);
// Get position again (which is the end of the file)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: seekStatus=%d', $seekStatus));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: seekStatus[%s]=%d', gettype($seekStatus), $seekStatus));
$size = $this->determineSeekPosition();
// Reset seek position to old
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size[%s]=%d', gettype($size), $size));
$this->seek($seekPosition);
// Return size
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size=%s - EXIT!', $size));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: size=%d - EXIT!', $size));
return $size;
}
* @throws NullPointerException If recovery of requested value instance failed
*/
public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) {
+ // Validate parameter
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('O:'.$registryKey.'/'.$extraKey);
+ if (empty($registryKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "registryKey" is empty');
+ }
+
try {
// Get the required instance
$this->valueInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
$this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
}
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
- } // END - if
+ }
// Is the value instance valid?
if (is_null($this->valueInstance)) {
// Get the requested instance
$this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
- } // END - if
+ }
}
/**
* @throws HelperGroupAlreadyCreatedException If the group was already created before
*/
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])) {
+ //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
+ if (empty($groupId)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupId" is empty');
+ } elseif (isset($this->groups[$groupId])) {
// Then throw an exception here
throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND);
- } // END - if
+ }
// Count one up
$this->totalCounter++;
if ($this->ifSubGroupOpenedPreviously()) {
// Close it automatically
$this->closePreviousSubGroupByContent();
- } // END - if
+ }
// Check if any group was opened before
if ($this->ifGroupOpenedPreviously() === false) {
// Then throw an exception
throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
- } // END - if
+ }
// Get previous group
$groupId = $this->getPreviousGroupId();
$groupId,
$this->groups[$groupId]['tag']
);
- } // END - if
+ }
// Add content to it and mark it as closed
$this->groups[$groupId]['content'] .= sprintf(
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])) {
+ if (empty($subGroupId)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "subGroupId" is empty');
+ } elseif (isset($this->subGroups[$subGroupId])) {
// Then throw an exception here
throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND);
- } // END - if
+ }
// Count one up
$this->totalCounter++;
if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception
throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
- } // END - if
+ }
// Get previous sub group
$subGroupId = $this->getPreviousSubGroupId();
if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
// Get it from opener
$content = sprintf('<!-- sub-group %s auto-closed //--></%s>', $subGroupId, $this->subGroups[$subGroupId]['tag']);
- } // END - if
+ }
// Add content to it and mark it as closed
$this->subGroups[$subGroupId]['content'] .= sprintf('<!-- sub-group %s closed (length: %s, tag: %s) //-->%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
if (isset($this->groups['header'])) {
// Then add it
$content .= $this->groups['header']['content'] . PHP_EOL;
- } // END - if
+ }
// Initiate content
$content .= $this->getContent();
// Something went wrong
$this->debugInstance(__METHOD__ . '(): Something unexpected happened here.');
}
- } // END - for
+ }
// Is footer content there?
if (isset($this->groups['footer'])) {
// Then add it
$content .= $this->groups['footer']['content'] . PHP_EOL;
- } // END - if
+ }
// Return it
//* DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
if (is_null($this->getValueInstance())) {
// Throws an exception here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ }
// Is the field set?
if ($this->getValueInstance()->isFieldSet($fieldName)) {
use Org\Mxchange\CoreFramework\Visitor\Visitable;
// Import SPL stuff
+use \InvalidArgumentException;
use \IteratorAggregate;
use \Countable;
* @return $isset Whether the group is valid
*/
public function isGroupSet (string $groupName) {
+ // Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName);
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ }
+
+ // Check on existence ...
return isset($this->listGroups[$groupName]);
}
* @throws ListGroupAlreadyAddedException If the given group is already added
*/
public function addGroup (string $groupName) {
+ // Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
- // Is the group already added?
- if ($this->isGroupSet($groupName)) {
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif ($this->isGroupSet($groupName)) {
// Throw the exception here
throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED);
}
* @throws NoListGroupException If the given group is not found
*/
public function addInstance (string $groupName, string $subGroup, Visitable $visitableInstance) {
- // Debug message
+ // Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
-
- // Is the group there?
- if (!$this->isGroupSet($groupName)) {
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif (empty($subGroup)) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "subGroup" is empty');
+ } elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
/**
* Gets an array from given list
*
- * @param $list The requested list
+ * @param $groupName The requested list
* @return $array The requested array
* @throws NoListGroupException If the given group is not found
*/
- public final function getArrayFromList ($list) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!');
-
+ public final function getArrayFromList ($groupName) {
// Is the group there?
- if ((!is_null($list)) && (!$this->isGroupSet($list))) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ' - CALLED!');
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif ((!is_null($groupName)) && (!$this->isGroupSet($groupName))) {
// Throw the exception here
- throw new NoListGroupException(array($this, $list), self::EXCEPTION_GROUP_NOT_FOUND);
+ throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
// Init array
$array = [];
// Is there another list?
- if (!is_null($list)) {
+ if (!is_null($groupName)) {
// Then get it as well
- $array = $this->listGroups[$list]->getArrayFromList(NULL);
+ $array = $this->listGroups[$groupName]->getArrayFromList(NULL);
}
// Walk through all entries
foreach ($this->listIndex as $hash) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash);
-
// Is the list entry set?
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: hash=' . $hash);
if ($this->isHashValid($hash)) {
// Add it
array_push($array, $this->listEntries[$hash]);
}
}
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',[]=' . count($array) . ' - EXIT!');
-
// Return it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName[' . gettype($groupName) . ']=' . $groupName . ',[]=' . count($array) . ' - EXIT!');
return $array;
}
* @throws NoListGroupException If the given group is not found
*/
public function addEntry (string $groupName, $entry) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
-
// Is the group already added?
- if (!$this->isGroupSet($groupName)) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
* @throws NoListGroupException If the given group is not found
*/
public function removeEntry (string $groupName, $entry) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
-
// Is the group already added?
- if (!$this->isGroupSet($groupName)) {
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-LIST: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!');
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
*/
protected function clearGroup (string $groupName) {
// Does this group exist?
- if (!$this->isGroupSet($groupName)) {
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
* @param $hash The hash we should validate
* @return $isValid Whether the given hash is valid
*/
- public final function isHashValid ($hash) {
+ public final function isHashValid (string $hash) {
+ // Validate parameter
+ if (empty($hash)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "hash" is empty');
+ }
+
// Check it
$isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash])));
*/
public function getArrayFromProtocolInstance (string $groupName) {
// Is the group valid?
- if (!$this->isGroupSet($groupName)) {
+ if (empty($groupName)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupName" is empty');
+ } elseif (!$this->isGroupSet($groupName)) {
// Throw the exception here
throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
}
* @return void
* @throws InvalidListHashException If the solved hash index is invalid
*/
- public function updateCurrentEntryByHash ($hash, array $entryArray) {
+ public function updateCurrentEntryByHash (string $hash, array $entryArray) {
// Is the hash valid?
- if (!$this->isHashValid($hash)) {
+ if (empty($hash)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "hash" is empty');
+ } elseif (!$this->isHashValid($hash)) {
// Throw an exception here, hashIndex is unknown at this point
throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH);
}
use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
// Import SPL stuff
+use \InvalidArgumentExeption;
use \IteratorAggregate;
/**
* @return void
*/
public function addInstance (string $instanceKey, Registerable $objectInstance) {
+ // Validate parameter
+ if (empty($instanceKey)) {
+ // Throw IAE
+ throw new InvalidArgumentExeption('Parameter "instanceKey" is empty');
+ }
+
+ // Set entry in generic array
$this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance);
}
* @return void
* @throws InvalidListHashException If the solved hash index is invalid
*/
- function updateCurrentEntryByHash ($hash, array $entryArray);
+ function updateCurrentEntryByHash (string $hash, array $entryArray);
/**
* "Getter" for an iterator instance of this list