]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/images/class_BaseImage.php
Continued:
[core.git] / framework / main / classes / images / class_BaseImage.php
index cb08935a0192d39382e5d17e483f4621d80e16ad..df66bc4d3de8f64a7a57ade9d04c9b73ccb62758 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Image;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
 
 /**
  * A general image class
@@ -63,20 +64,20 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
        /**
         * Background color in RGB
         */
-       private $backgroundColor = array(
+       private $backgroundColor = [
                'red'   => '',
                'green' => '',
                'blue'  => ''
-       );
+       ];
 
        /**
         * Foreground color in RGB
         */
-       private $foregroundColor = array(
+       private $foregroundColor = [
                'red'   => '',
                'green' => '',
                'blue'  => ''
-       );
+       ];
 
        /**
         * Current choosen color array
@@ -103,6 +104,11 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         */
        private $groupable = 'single';
 
+       /**
+        * Template engine instance
+        */
+       private $templateInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -121,7 +127,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $colorChannel   Red, green or blue channel?
         * @param       $colorValue             Value to set
         */
-       private final function setColor ($colorMode, $colorChannel, $colorValue) {
+       private final function setColor (string $colorMode, string $colorChannel, $colorValue) {
                // Construct the eval() command
                $eval = sprintf("\$this->%s['%s'] = \"%s\";",
                        $colorMode,
@@ -140,7 +146,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $width  Width of the image
         * @return      void
         */
-       public final function setWidth ($width) {
+       public final function setWidth (int $width) {
                $this->width = $width;
        }
 
@@ -159,7 +165,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $height Height of the image
         * @return      void
         */
-       public final function setHeight ($height) {
+       public final function setHeight (int $height) {
                $this->height = $height;
        }
 
@@ -267,7 +273,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         * @todo        Find something usefull for this method.
         */
-       public function initImageString ($groupable = 'single') {
+       public function initImageString (string $groupable = 'single') {
                $this->groupable = $groupable;
        }
 
@@ -288,11 +294,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        public final function setRed ($red) {
-               // Get array name
-               $arrayName = $this->colorMode;
-
                // Set image color
-               $this->setColor($arrayName, 'red', $red);
+               $this->setColor($this->colorMode, 'red', $red);
        }
 
        /**
@@ -302,11 +305,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        public final function setGreen ($green) {
-               // Get array name
-               $arrayName = $this->colorMode;
-
                // Set image color
-               $this->setColor($arrayName, 'green', $green);
+               $this->setColor($this->colorMode, 'green', $green);
        }
 
        /**
@@ -316,11 +316,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @return      void
         */
        public final function setBlue ($blue) {
-               // Get array name
-               $arrayName = $this->colorMode;
-
                // Set image color
-               $this->setColor($arrayName, 'blue', $blue);
+               $this->setColor($this->colorMode, 'blue', $blue);
        }
 
        /**
@@ -348,8 +345,8 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $imageType              Type to set in image
         * @return      void
         */
-       protected final function setImageType ($imageType) {
-               $this->imageType = (string) $imageType;
+       protected final function setImageType (string $imageType) {
+               $this->imageType = $imageType;
        }
 
        /**
@@ -395,7 +392,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $x      X coordinate
         * @return      void
         */
-       public final function setX ($x) {
+       public final function setX (int $x) {
                $this->x = $x;
        }
 
@@ -414,7 +411,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $y      Y coordinate
         * @return      void
         */
-       public final function setY ($y) {
+       public final function setY (int $y) {
                $this->y = $y;
        }
 
@@ -433,7 +430,7 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $fontSize       Font size for strings
         * @return      void
         */
-       public final function setFontSize ($fontSize) {
+       public final function setFontSize (int $fontSize) {
                $this->fontSize = $fontSize;
        }
 
@@ -452,10 +449,29 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         * @param       $stringName             String name to set
         * @return      void
         */
-       public final function setStringName($stringName) {
+       public final function setStringName(string $stringName) {
                $this->stringName = $stringName;
        }
 
+       /**
+        * Setter for template engine instances
+        *
+        * @param       $templateInstance       An instance of a CompileableTemplate class
+        * @return      void
+        */
+       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
+               $this->templateInstance = $templateInstance;
+       }
+
+       /**
+        * Getter for template engine instances
+        *
+        * @return      $templateInstance       An instance of a CompileableTemplate class
+        */
+       public final function getTemplateInstance () {
+               return $this->templateInstance;
+       }
+
        /**
         * Finish this image by producing it
         *