]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/helper/captcha/images/class_ImageHelper.php
Continued:
[core.git] / framework / main / classes / helper / captcha / images / class_ImageHelper.php
index da87bb80dcb72bde873c64b80b663ff1fcdd3e12..ca6e53f08efbcaf61fffbc4c7f63130dfd2adb2b 100644 (file)
@@ -12,7 +12,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -53,25 +53,25 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
        /**
         * Array for background color values
         */
-       private $backgroundColor = array(
+       private $backgroundColor = [
                'red'   => 0,
                'green' => 0,
                'blue'  => 0
-       );
+       ];
 
        /**
         * Array for foreground color values
         */
-       private $foregroundColor = array(
+       private $foregroundColor = [
                'red'   => 0,
                'green' => 0,
                'blue'  => 0
-       );
+       ];
 
        /**
         * All image strings
         */
-       private $imageStrings = array();
+       private $imageStrings = [];
 
        /**
         * Current string name
@@ -88,7 +88,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -100,7 +100,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @param       $imageType                      Type of the image
         * @return      $helperInstance         A preparedf instance of this helper
         */
-       public static final function createImageHelper (CompileableTemplate $templateInstance, $imageType) {
+       public static final function createImageHelper (CompileableTemplate $templateInstance, string $imageType) {
                // Get new instance
                $helperInstance = new ImageHelper();
 
@@ -123,8 +123,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @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;
        }
 
        /**
@@ -142,8 +142,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @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;
        }
 
        /**
@@ -161,8 +161,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @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;
        }
 
        /**
@@ -180,8 +180,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @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;
        }
 
        /**
@@ -199,8 +199,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @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;
        }
 
        /**
@@ -224,13 +224,13 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
                // 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;
@@ -249,13 +249,13 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
                // 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;
@@ -267,7 +267,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         *
         * @param       $stringName             String name (identifier)
         */
-       public function addTextLine ($stringName) {
+       public function addTextLine (string $stringName) {
                // Create the image string
                $this->imageStrings[$stringName] = array(
                        'x'      => '',
@@ -286,8 +286,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @param       $imageString    A message to display in image
         * @return      void
         */
-       public final function setImageString ($imageString) {
-               $this->imageStrings[$this->currString]['string'] = (string) $imageString;
+       public final function setImageString (string $imageString) {
+               $this->imageStrings[$this->currString]['string'] = $imageString;
        }
 
        /**
@@ -306,9 +306,9 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
         * @param       $y      Y coordinate
         * @return      void
         */
-       public final function setCoord ($x, $y) {
-               $this->imageStrings[$this->currString]['x'] = (int) $x;
-               $this->imageStrings[$this->currString]['y'] = (int) $y;
+       public final function setCoord (int $x, int $y) {
+               $this->imageStrings[$this->currString]['x'] = $x;
+               $this->imageStrings[$this->currString]['y'] = $y;
        }
 
        /**
@@ -339,7 +339,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
                // Random font size?
                if ($fontSize === 'rand') {
                        $fontSize = $this->getRngInstance()->randomNumber(4, 9);
-               } // END - if
+               }
 
                $this->imageStrings[$this->currString]['size'] = (int) $fontSize;
        }
@@ -390,7 +390,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate {
                        $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();