* @param $realClass Class name (string)
* @return void
*/
- public final function setRealClass (string $realClass): void {
+ private function setRealClass (string $realClass): void {
// Set real class
$this->realClass = $realClass;
}
* @param $key Optional key, if none provided, a random key will be generated
* @return $encrypted Encrypted string
*/
- public function encryptString (string $str, string $key = NULL) {
+ public function encryptString (string $str, string $key = NULL): string {
// Encrypt the string through the stream
$encrypted = $this->cryptoStreamInstance->encryptStream($str, $key);
* @param $encrypted Encrypted string
* @return $str The unencrypted string
*/
- public function decryptString (string $encrypted) {
+ public function decryptString (string $encrypted): string {
// Encrypt the string through the stream
$str = $this->cryptoStreamInstance->decryptStream($encrypted);
);
// And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-FRAMEWORK-SYSTEM: cacheKey=' . $cacheKey . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-DATABASE-FRONTEND: cacheKey=' . $cacheKey . ' - EXIT!');
return $cacheKey;
}
* @param $status New response status
* @return void
*/
- public final function setResponseStatus (string $status) {
+ public final function setResponseStatus (string $status): void {
$this->responseStatus = $status;
}
* @param $value Value of header element
* @return void
*/
- public final function addHeader (string $name, $value) {
+ public final function addHeader (string $name, string $value): void {
$this->responseHeaders[$name] = $value;
}
*
* @return void
*/
- public final function resetResponseHeaders () {
+ public final function resetResponseHeaders (): void {
$this->responseHeaders = [];
}
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- public final function writeToBody (string $output) {
+ public final function writeToBody (string $output): void {
$this->responseBody .= $output;
}
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- public final function setResponseBody ($output) {
+ public final function setResponseBody (string $output): void {
$this->responseBody = $output;
}
* @param $responseType Response type
* @return void
*/
- protected final function setResponseType (string $responseType) {
+ protected final function setResponseType (string $responseType): void {
$this->responseType = $responseType;
}
* @param $responseType Response type
* @return void
*/
- public final function getResponseType () {
+ public final function getResponseType (): string {
return $this->responseType;
}
* @param $messageId The message id we shall add
* @return void
*/
- public final function addFatalMessage (string $messageId) {
+ public final function addFatalMessage (string $messageId): void {
// Adds the resolved message id to the fatal message list
$this->addFatalMessagePlain(FrameworkBootstrap::getLanguageInstance()->getMessage($messageId));
}
* @param $message The plain message we shall add
* @return void
*/
- public final function addFatalMessagePlain (string $message) {
+ public final function addFatalMessagePlain (string $message): void {
// Adds the resolved message id to the fatal message list
$this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message);
}
* @throws ResponseHeadersAlreadySentException Thrown if headers are
* already sent
*/
- public function flushBuffer (bool $force = false) {
+ public function flushBuffer (bool $force = false): void {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
// Headers already sent?
- if ((headers_sent()) && ($force === false)) {
+ if (!$force && headers_sent()) {
// Headers are already sent!
throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
- } elseif (!headers_sent()) {
+ } elseif ($force || !headers_sent()) {
// Send headers out
header('HTTP/1.1 ' . $this->responseStatus);
*
* @return $defaultCommand Default command for this response
*/
- public function determineDefaultCommand () {
+ public function determineDefaultCommand (): string {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
*
* @return $responseInstance A prepared instance of this class
*/
- public static final function createConsoleResponse () {
+ public static final function createConsoleResponse (): Responseable {
// Get a new instance
$responseInstance = new ConsoleResponse();
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- public function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL) {
+ public function addCookie (string $cookieName, string $cookieValue, bool $encrypted = FALSE, int $expires = NULL): void {
//* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- public function redirectToConfiguredUrl ($configEntry) {
+ public function redirectToConfiguredUrl (string $configEntry): void {
DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
* @param $cookieName Cookie to expire
* @return void
*/
- public function expireCookie ($cookieName) {
+ public function expireCookie (string $cookieName): void {
DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
* @param $cookieName Cookie to refresh
* @return void
*/
- public function refreshCookie ($cookieName) {
+ public function refreshCookie (string $cookieName): void {
DebugMiddleware::getSelfInstance()->partialStub('Naturally unimplemented in console response.');
}
* @return void
* @throws ResponseHeadersAlreadySentException Thrown if headers are already sent
*/
- public function flushBuffer ($force = false) {
+ public function flushBuffer (bool $force = false): void {
DebugMiddleware::getSelfInstance()->partialStub('Please implement this class.');
}
*
* @return $responseInstance A prepared instance of this class
*/
- public static final function createHtmlResponse () {
+ public static final function createHtmlResponse (): Responseable {
// Get a new instance
$responseInstance = new HtmlResponse();
* @todo If the return statement is removed and setcookie() commented out,
* @todo this will send only one cookie out, the first one.
*/
- public function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL) {
+ public function addCookie (string $cookieName, string $cookieValue, bool $encrypted = FALSE, int $expires = NULL): void {
//* DEBUG: */ echo $cookieName.'='.$cookieValue."<br />\n";
// Are headers already sent?
if (headers_sent()) {
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- public function redirectToConfiguredUrl ($configEntry) {
+ public function redirectToConfiguredUrl (string $configEntry): void {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
* @param $cookieName Cookie to expire
* @return void
*/
- public function expireCookie (string $cookieName) {
+ public function expireCookie (string $cookieName): void {
// Is the cookie there?
if (isset($_COOKIE[$cookieName])) {
// Then expire it with 20 minutes past
* @param $cookieName Cookie to refresh
* @return void
*/
- public function refreshCookie (string $cookieName) {
+ public function refreshCookie (string $cookieName): void {
// Only update existing cookies
if (isset($_COOKIE[$cookieName])) {
// Update the cookie
*
* @return $responseInstance A prepared instance of this class
*/
- public static final function createImageResponse () {
+ public static final function createImageResponse (): Responseable {
// Get a new instance
$responseInstance = new ImageResponse();
* @param $imageInstance An instance of an image
* @return void
*/
- public final function setImageInstance (BaseImage $imageInstance) {
+ public final function setImageInstance (BaseImage $imageInstance): void {
$this->imageInstance = $imageInstance;
}
*
* @return $imageInstance An instance of an image
*/
- public final function getImageInstance () {
+ public final function getImageInstance (): BaseImage {
return $this->imageInstance;
}
* @todo If the return statement is removed and setcookie() commented out,
* @todo this will send only one cookie out, the first one.
*/
- public function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL) {
+ public function addCookie (string $cookieName, string $cookieValue, bool $encrypted = FALSE, int $expires = NULL): void {
// Are headers already sent?
if (headers_sent()) {
// Throw an exception here
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- public function redirectToConfiguredUrl (string $configEntry) {
+ public function redirectToConfiguredUrl (string $configEntry): void {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
* already sent with an exception
* @return void
*/
- public function flushBuffer (bool $force = false) {
+ public function flushBuffer (bool $force = false): void {
// Finish the image
$this->getImageInstance()->finishImage();
* @param $cookieName Cookie to expire
* @return void
*/
- public function expireCookie (string $cookieName) {
+ public function expireCookie (string $cookieName): void {
// Is the cookie there?
if (isset($_COOKIE[$cookieName])) {
// Then expire it with 20 minutes past
* @param $cookieName Cookie to refresh
* @return void
*/
- public function refreshCookie (string $cookieName) {
+ public function refreshCookie (string $cookieName): void {
// Only update existing cookies
if (isset($_COOKIE[$cookieName])) {
// Update the cookie
*/
public static function isBase64Encoded (string $encodedData): bool {
// Check parameter
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: encodedData=%s - CALLED!', $encodedData));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: encodedData=%s - CALLED!', $encodedData));
if (empty($encodedData)) {
// Throw IAE
throw new InvalidArgumentException('Parameter "encodedData" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
$isBase64 = (@base64_decode($encodedData, true) !== false);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-FRAMEWORK-SYSTEM: isBase64=%d - EXIT!', intval($isBase64)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: isBase64=%d - EXIT!', intval($isBase64)));
return $isBase64;
}
* @param $withFixed Whether to include a fixed salt (not recommended in p2p applications)
* @return $hashed The hashed and salted string
*/
- function hashString (string $str, string $oldHash = '', bool $withFixed = true);
+ function hashString (string $str, string $oldHash = '', bool $withFixed = true): string;
/**
* 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 (string $str, string $key = NULL);
+ function encryptString (string $str, string $key = NULL): string;
/**
* Decrypt the string with fixed salt
* @param $encrypted Encrypted string
* @return $str The unencrypted string
*/
- function decryptString (string $encrypted);
+ function decryptString (string $encrypted): string;
}
* @param $status New response status
* @return void
*/
- function setResponseStatus (string $status);
+ function setResponseStatus (string $status): void;
/**
* Adds a header to the response. This method "wraps" the direct header()
* @param $value Value of header element
* @return void
*/
- function addHeader (string $name, $value);
+ function addHeader (string $name, string $value): void;
/**
* "Writes" data to the response body
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- function writeToBody (string $output);
+ function writeToBody (string $output): void;
/**
* Flushs the cached HTTP response to the outer world
* @throws ResponseHeadersAlreadySentException Thrown if headers are
* already sent
*/
- function flushBuffer (bool $force = false);
+ function flushBuffer (bool $force = false): void;
/**
* Adds a fatal message id to the response. The added messages can then be
* @param $messageId The message id we shall add
* @return void
*/
- function addFatalMessage (string $messageId);
+ function addFatalMessage (string $messageId): void;
/**
* Adds a cookie to the response
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- function addCookie (string $cookieName, $cookieValue, bool $encrypted = FALSE, int $expires = NULL);
+ function addCookie (string $cookieName, string $cookieValue, bool $encrypted = FALSE, int $expires = NULL): void;
/**
* Redirect to a configured URL. The URL can be absolute or relative. In
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- function redirectToConfiguredUrl (string $configEntry);
+ function redirectToConfiguredUrl (string $configEntry): void;
/**
* Expires the given cookie if it is set
* @param $cookieName Cookie to expire
* @return void
*/
- function expireCookie (string $cookieName);
+ function expireCookie (string $cookieName): void;
/**
* Refreshs a given cookie. This will make the cookie live longer
* @param $cookieName Cookie to refresh
* @return void
*/
- function refreshCookie (string $cookieName);
+ function refreshCookie (string $cookieName): void;
}