* @return $count Count of all criteria entries
* @throws InvalidArgumentException If a parameter is not valid
*/
- protected final function count (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ protected final function count (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): int {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaType));
if (empty($criteriaType)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public function isKeySet (string $criteriaType, string $criteriaKey) {
+ public function isKeySet (string $criteriaType, string $criteriaKey): bool {
// Check parameters
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s,criteriaKey=%s - CALLED!', strtoupper($criteriaType), $criteriaType, $criteriaKey));
if (empty($criteriaType)) {
* @return $isset Whether key is set
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function isChoiceKeySet (string $criteriaKey) {
+ public function isChoiceKeySet (string $criteriaKey): bool {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
if (empty($criteriaKey)) {
* @return $isset Whether key is set
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function isExcludeKeySet (string $criteriaKey) {
+ public function isExcludeKeySet (string $criteriaKey): bool {
// Validate parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
if (empty($criteriaKey)) {
* @param $frontendConfigEntry Configuration entry which hold the frontend class' name
* @return void
*/
- public final function setFrontendConfigEntry (string $frontendConfigEntry) {
+ public final function setFrontendConfigEntry (string $frontendConfigEntry): void {
$this->frontendConfigEntry = $frontendConfigEntry;
}
*
* @return $frontendConfigEntry Configuration entry which hold the frontend class' name
*/
- public final function getFrontendConfigEntry () {
+ public final function getFrontendConfigEntry (): string {
return $this->frontendConfigEntry;
}
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function getCriteriaArray (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public final function getCriteriaArray (string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): array {
// Check parameters
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaType));
if (empty($criteriaType)) {
*
* @return $criteria
*/
- public final function getCriteriaChoiceArray () {
+ public final function getCriteriaChoiceArray (): array {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: CALLED!', strtoupper($criteriaType)));
return $this->getCriteriaArray(Criteria::CRITERIA_TYPE_CHOICE);
}
*
* @return $criteria
*/
- public final function getCriteriaExcludeArray () {
+ public final function getCriteriaExcludeArray (): array {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
return $this->getCriteriaArray(Criteria::CRITERIA_TYPE_EXCLUDE);
}
* @param $criteriaKey Criteria key to unset
* @return void
*/
- public final function unsetCriteria (string $criteriaKey) {
+ public final function unsetCriteria (string $criteriaKey): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public final function addCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[]=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaType));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public final function setCriteria (string $criteriaKey, $criteriaValue, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaValue[]=%s$criteriaValue,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, gettype($criteriaValue), $criteriaType));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If $criteriaValue has an unexpected type
*/
- public final function addChoiceCriteria (string $criteriaKey, $criteriaValue) {
+ public final function addChoiceCriteria (string $criteriaKey, mixed $criteriaValue): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s,criteriaValue[]=%s - CALLED!', $criteriaKey, gettype($criteriaValue)));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If $criteriaValue has an unexpected type
*/
- public final function addExcludeCriteria (string $criteriaKey, $criteriaValue) {
+ public final function addExcludeCriteria (string $criteriaKey, mixed $criteriaValue): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s,criteriaValue[%s]=%s - CALLED!', $criteriaKey, gettype($criteriaValue), $criteriaValue));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): void {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,configEntry=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, $configEntry, $criteriaType));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): mixed {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: criteriaKey=%s,criteriaType=%s - CALLED!', strtoupper($criteriaType), $criteriaKey, $criteriaType));
if (empty($criteriaKey)) {
* @return $value Whether the value of the critera or false
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function getCriteriaChoiceElemnent (string $criteriaKey) {
+ public function getCriteriaChoiceElemnent (string $criteriaKey): mixed {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
if (empty($criteriaKey)) {
* @return $value Whether the value of the critera or false
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function getCriteriaExcludeElemnent (string $criteriaKey) {
+ public function getCriteriaExcludeElemnent (string $criteriaKey): mixed {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: criteriaKey=%s - CALLED!', $criteriaKey));
if (empty($criteriaKey)) {
* @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
*/
- public function ifEntryMatches (array $entryArray, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public function ifEntryMatches (array $entryArray, string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): bool {
// Check parameters
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: entryArray()=%d,criteriaType=%s - CALLED!', strtoupper($criteriaType), count($entryArray), $criteriaType));
if (count($entryArray) == 0) {
* @return $matches Whether the entry matches or not
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function ifChoiceMatches (array $entryArray) {
+ public function ifChoiceMatches (array $entryArray): bool {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: entryArray()=%d - CALLED!', count($entryArray)));
if (count($entryArray) == 0) {
* @return $matches Whether the entry matches or not
* @throws InvalidArgumentException If a parameter is not valid
*/
- public function ifExcludeMatches (array $entryArray) {
+ public function ifExcludeMatches (array $entryArray): bool {
// Check parameter
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: entryArray()=%d - CALLED!', count($entryArray)));
if (count($entryArray) == 0) {
* @throws UnexpectedValueException If a parameter contains an unexpected/unsupported value
* @throws BadMethodCallException If this method is invoked before $criteriaType has been initialized
*/
- public function getCacheKey (array $onlyKeys = [], string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT) {
+ public function getCacheKey (array $onlyKeys = [], string $criteriaType = Criteria::CRITERIA_TYPE_DEFAULT): string {
// Check parameters
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-CRITERIA: onlyKeys()=%d,criteriaType=%s - CALLED!', strtoupper($criteriaType), count($onlyKeys), $criteriaType));
if (empty($criteriaType)) {
* @param $onlyKeys Only use these keys for a cache key
* @return $cacheKey The key suitable for the cache system
*/
- public function getCacheKeyChoice (array $onlyKeys = []) {
+ public function getCacheKeyChoice (array $onlyKeys = []): string {
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: onlyKeys()=%d - CALLED!', count($onlyKeys)));
* @param $onlyKeys Only use these keys for a cache key
* @return $cacheKey The key suitable for the cache system
*/
- public function getCacheKeyExclude (array $onlyKeys = []) {
+ public function getCacheKeyExclude (array $onlyKeys = []): string {
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-CRITERIA: onlyKeys()=%d - CALLED!', count($onlyKeys)));
*
* @return $count Count of all criteria entries
*/
- public final function countChoice () {
+ public final function countChoice (): int {
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
return $this->count(Criteria::CRITERIA_TYPE_CHOICE);
*
* @return $count Count of all criteria entries
*/
- public final function countExclude () {
+ public final function countExclude (): int {
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-CRITERIA: CALLED!');
return $this->count(Criteria::CRITERIA_TYPE_EXCLUDE);
*
* @return $frontendInstance An instance of the created frontend class
*/
- public static final function createNewsDatabaseFrontend () {
+ public static final function createNewsDatabaseFrontend (): DatabaseFrontend {
// Get a new instance
$frontendInstance = new NewsDatabaseFrontend();
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
- * @throws LogicException If there is no object being set
*/
public function readFromFile (): string {
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
- if (is_null($this->getFileObject())) {
+ if (!$this->isFileObjectValid()) {
// Pointer not initialized
throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_object($this->getFileObject())) {
- // Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Read data from the file pointer and return it
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
// Import SPL stuff
+use \InvalidArgumentException;
use \SplFileInfo;
use \SplFileObject;
* @return $data Data read from file
* @throws OutOfBoundsException If the position is not seekable
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
- * @throws LogicException If $fileObject is not an object
*/
public function read (int $bytes = 0): string {
// Some sanity checks
if ($bytes < 0) {
// Cannot be below zero
throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
- } elseif (is_null($this->getFileObject())) {
+ } elseif (!$this->isFileObjectValid()) {
// Pointer not initialized
throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_object($this->getFileObject())) {
- // Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Is $bytes set?
* @return mixed Number of writes bytes or false on error
* @throws InvalidArgumentException If a parameter is invalid
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
- * @throws LogicException If there is no object being set
*/
public function writeToFile (string $dataStream): mixed {
// Validate parameter and class own attributes
if (empty($dataStream)) {
// Empty data stream
throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
- } elseif (is_null($this->getFileObject())) {
+ } elseif (!$this->isFileObjectValid()) {
// Pointer not initialized
throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_object($this->getFileObject())) {
- // Pointer is not a valid resource!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Write data to the file pointer and return written bytes
* @param $dataStream The data stream we shall write to the file
* @return mixed Number of writes bytes or false on error
* @throws NullPointerException If the file pointer instance is not set by setFileObject()
- * @throws LogicException If there is no object being set
*/
public function writeToFile (string $dataStream): mixed {
// Validate parameter
if (empty($dataStream)) {
// Invalid parameter
throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
- } elseif (is_null($this->getFileObject())) {
+ } elseif (!$this->isFileObjectValid()) {
// Pointer not initialized
throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_object($this->getFileObject())) {
- // Pointer is not a valid object!
- throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
}
// Write data to the file pointer and return written bytes
* @param $infoInstance An instance of a SplFileInfo class
* @return $fileInstance An instance of this File class
*/
- public final static function createCsvInputFile (SplFileInfo $infoInstance) {
+ public final static function createCsvInputFile (SplFileInfo $infoInstance): CsvInputStreamer {
// Get a new instance
$fileInstance = new CsvInputFile();
* @throws InvalidArgumentException If a parameter is invalid
* @throws UnexpectedValueException If the array count is not matching expected count
*/
- public function readCsvFileLine (string $columnSeparator, int $expectedMatches = 0) {
+ public function readCsvFileLine (string $columnSeparator, int $expectedMatches = 0): array {
// Validate parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] columnSeparator=%s,expectedMatches=%d - CALLED!', __METHOD__, __LINE__, $columnSeparator, $expectedMatches));
if (strlen($columnSeparator) === 0) {
if (empty($data)) {
// Yes, then skip below code
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] Read data is an empty line - EXIT!', __METHOD__, __LINE__));
- return;
+ return [];
}
// Parse data
* @param $columnSeparator Character to use separting columns
* @return $lineArray An indexed array with the read line
*/
- private function parseDataToIndexedArray (string $data, string $columnSeparator) {
+ private function parseDataToIndexedArray (string $data, string $columnSeparator): array {
// Init return array
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] data()=%d,columnSeparator=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $columnSeparator));
$lineArray = [];
* @return void
* @throws InvalidArgumentException If a parameter has an invalid value
*/
- protected function initFile (string $fileName) {
+ protected function initFile (string $fileName): void {
// Check parameter
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-OUTPUT-TEXT-FILE: fileName=%s - CALLED!', $fileName));
if (empty($fileName)) {
* Create a new web output system and set the content type
*
* @param $contentType A valid content-type
- * @return $debugInstance An instance of this middleware class
+ * @return $debugInstance An instance of an OutputStreamer class
*/
- public static final function createConsoleOutput (string $contentType) {
+ public static final function createConsoleOutput (string $contentType): OutputStreamer {
// Cast the content-type to string
$contentType = trim($contentType);
/**
* Getter for an instance of this class
*
- * @return $consoleInstance An instance of this class
+ * @return $consoleInstance An instance of an OutputStreamer class
*/
- public static final function getInstance() {
+ public static final function getInstance(): OutputStreamer {
// Is the self-instance already set?
if (is_null(self::$consoleInstance)) {
$contentType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('web_content_type');
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function output (string $outStream = '', bool $stripTags = false) {
+ public final function output (string $outStream = '', bool $stripTags = false): void {
print trim($outStream) . PHP_EOL;
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData (string $data) {
+ public function streamData (string $data): string {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData (string $data) {
+ public function streamData (string $data): string {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called
*/
- public function streamData (string $data) {
+ public function streamData (string $data): string {
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
*
* @return $webInstance An instance of an OutputStreamer class
*/
- public static final function createWebOutput () {
+ public static final function createWebOutput (): OutputStreamer {
// Is the self-instance already set?
if (is_null(self::$webInstance)) {
// Get a new instance and set it
* @param $stripTags Whether HTML tags shall be stripped out
* @return void
*/
- public final function output (string $outStream = '', bool $stripTags = false) {
+ public final function output (string $outStream = '', bool $stripTags = false): void {
print(stripslashes($outStream));
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
- public function streamData (string $data): mixed {
+ public function streamData (string $data): string {
self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return $data The data (string mostly) to "stream"
* @throws UnsupportedOperationException If this method is called (which is a mistake)
*/
- public function streamData (string $data): mixed {
+ public function streamData (string $data): string {
self::createDebugInstance(__CLASS__, __LINE__)->warningMessage('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException([$this, __FUNCTION__], FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
}
* @return void
* @todo Find a way of casting here. "(int)" might destroy the user id > 32766
*/
- public final function setUserId (int $userId) {
+ public final function setUserId (int $userId): void {
$this->userId = $userId;
}
* @param $email The email to set
* @return void
*/
- protected final function setEmail (string $email) {
+ protected final function setEmail (string $email): void {
$this->email = $email;
}
* @return $userInstance An instance of this user class
* @todo Add more ways over creating user classes
*/
- public static final function createGuestByRequest (Requestable $requestInstance) {
+ public static final function createGuestByRequest (Requestable $requestInstance): ManageableGuest {
// Determine if by email or username
if (!is_null($requestInstance->getRequestElement('username'))) {
// Username supplied
* @throws UsernameMissingException If the username does not exist
* @throws UserNoGuestException If the user is no guest account
*/
- public static final function createGuestByUsername (string $userName) {
+ public static final function createGuestByUsername (string $userName): ManageableGuest {
// Check parameter
if (empty($userName)) {
// Throw IAE
* @param $email Email address of the user
* @return $userInstance An instance of this user class
*/
- public static final function createGuestByEmail (string $email) {
+ public static final function createGuestByEmail (string $email): ManageableGuest {
// Check parameter
if (empty($email)) {
// Throw IAE
* @param $requestInstance A requestable class instance
* @return void
*/
- public function updateLastActivity (Requestable $requestInstance) {
+ public function updateLastActivity (Requestable $requestInstance): void {
// No activity will be logged for guest accounts
}
* @throws UsernameMissingException If the username does not exist
* @throws UnexpectedGuestAccountException If the user status is 'guest'
*/
- public static final function createMemberByUsername (string $userName) {
+ public static final function createMemberByUsername (string $userName): ManageableMember {
// Check parameter
if (empty($userName)) {
// Throw IAE
* @param $email Email address of the user
* @return $userInstance An instance of this user class
*/
- public static final function createMemberByEmail (string $email) {
+ public static final function createMemberByEmail (string $email): ManageableMember {
// Check parameter
if (empty($email)) {
// Throw IAE
* @return $userInstance An instance of this user class
* @todo Add more ways over creating user classes
*/
- public static final function createMemberByRequest (Requestable $requestInstance) {
+ public static final function createMemberByRequest (Requestable $requestInstance): ManageableMember {
// Determine if by email or username
if (!is_null($requestInstance->getRequestElement('username'))) {
// Username supplied
* @param $requestInstance A requestable class instance
* @return void
*/
- public function updateLastActivity (Requestable $requestInstance) {
+ public function updateLastActivity (Requestable $requestInstance): void {
// Set last action
$lastAction = $requestInstance->getRequestElement('action');
* @return $lineArray An index array with the read line
* @throws InvalidArgumentException If a parameter is invalid
*/
- function readCsvFileLine (string $columnSeparator, int $expectedMatches = 0);
+ function readCsvFileLine (string $columnSeparator, int $expectedMatches = 0): array;
}
* @param $data The data (string mostly) to "stream"
* @return $data The data (string mostly) to "stream"
*/
- function streamData (string $data);
+ function streamData (string $data): string;
}
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- function encryptStream (string $str, string $key = NULL);
+ function encryptStream (string $str, string $key = NULL): string;
/**
* Decrypt the string with fixed salt
* @param $key Optional key, if none provided, a random key will be generated
* @return $str The unencrypted string
*/
- function decryptStream (string $encrypted, string $key = NULL);
+ function decryptStream (string $encrypted, string $key = NULL): string;
}
*/
function ifPasswordHashMatches (Requestable $requestInstance): bool;
+ /**
+ * Updates the last activity timestamp and last performed action in the
+ * database result.
+ *
+ * @param $requestInstance A requestable class instance
+ * @return void
+ */
+ function updateLastActivity (Requestable $requestInstance): void;
+
}