*
* @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
*
/**
* 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
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
* @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();
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
* @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;
}
/**
// 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;
// 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;
*
* @param $stringName String name (identifier)
*/
- public function addTextLine ($stringName) {
+ public function addTextLine (string $stringName) {
// Create the image string
$this->imageStrings[$stringName] = array(
'x' => '',
* @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;
}
/**
* @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;
}
/**
// Random font size?
if ($fontSize === 'rand') {
$fontSize = $this->getRngInstance()->randomNumber(4, 9);
- } // END - if
+ }
$this->imageStrings[$this->currString]['size'] = (int) $fontSize;
}
$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();