From 409f893a2e94bf8e55fd4f6ceca901aec1bc75a9 Mon Sep 17 00:00:00 2001 From: ve3 Date: Tue, 12 Mar 2024 16:15:36 +0700 Subject: [PATCH] Update methods in `CalculationTrait` to be public. This allowed usage from outside this package. --- Rundiz/Image/ImageInterface.php | 2 +- Rundiz/Image/Traits/CalculationTrait.php | 6 +++--- tests/phpunit/ExtendedAbstractImage.php | 27 ------------------------ 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/Rundiz/Image/ImageInterface.php b/Rundiz/Image/ImageInterface.php index 405cd88..2120504 100644 --- a/Rundiz/Image/ImageInterface.php +++ b/Rundiz/Image/ImageInterface.php @@ -3,7 +3,7 @@ * PHP Image manipulation class. * * @package Image - * @version 3.1.1 + * @version 3.1.2 * @author Vee W. * @license http://opensource.org/licenses/MIT */ diff --git a/Rundiz/Image/Traits/CalculationTrait.php b/Rundiz/Image/Traits/CalculationTrait.php index 3a9f9b1..4b16f94 100644 --- a/Rundiz/Image/Traits/CalculationTrait.php +++ b/Rundiz/Image/Traits/CalculationTrait.php @@ -222,7 +222,7 @@ protected function calculateImageSizeRatio($width, $height) * @param int $canvasWidth Canvas size. * @return int Calculated size. */ - protected function calculateStartXOfCenter($objWidth, $canvasWidth) + public function calculateStartXOfCenter($objWidth, $canvasWidth) { if (!is_numeric($objWidth) || !is_numeric($canvasWidth)) { return 0; @@ -246,7 +246,7 @@ protected function calculateStartXOfCenter($objWidth, $canvasWidth) * @return array Return array with width as index 0, height as index 1. * @throws \InvalidArgumentException Throw exception if invalid argument type was specified. */ - protected function calculateWatermarkImageStartXY($wmStartX, $wmStartY, $imgWidth, $imgHeight, $wmWidth, $wmHeight, array $options = []) + public function calculateWatermarkImageStartXY($wmStartX, $wmStartY, $imgWidth, $imgHeight, $wmWidth, $wmHeight, array $options = []) { if (!is_numeric($imgHeight) || !is_numeric($imgWidth)) { throw new \InvalidArgumentException('The $imgWidth and $imgHeight must be number.'); @@ -313,7 +313,7 @@ protected function calculateWatermarkImageStartXY($wmStartX, $wmStartY, $imgWidt * @param int $number Alpha number (0 to 127). 127 is completely transparent. * @return string Return RGBA value (1.00 to 0.00). 0.00 is completely transparent. */ - protected function convertAlpha127ToRgba($number) + public function convertAlpha127ToRgba($number) { $alpha_min = 0; // 100% $alpha_max = 127; // 0% diff --git a/tests/phpunit/ExtendedAbstractImage.php b/tests/phpunit/ExtendedAbstractImage.php index 98c1bfc..a4df588 100644 --- a/tests/phpunit/ExtendedAbstractImage.php +++ b/tests/phpunit/ExtendedAbstractImage.php @@ -47,38 +47,11 @@ public function calculateVariableSpace($currentSize, $minSize, $minSpace, $diffe }// calculateVariableSpace - /** - * {@inheritDoc} - */ - public function calculateStartXOfCenter($objWidth, $canvasWidth) - { - return parent::calculateStartXOfCenter($objWidth, $canvasWidth); - }// calculateStartXOfCenter - - - /** - * {@inheritDoc} - */ - public function calculateWatermarkImageStartXY($wmStartX, $wmStartY, $imgWidth, $imgHeight, $wmWidth, $wmHeight, array $options = []) - { - return parent::calculateWatermarkImageStartXY($wmStartX, $wmStartY, $imgWidth, $imgHeight, $wmWidth, $wmHeight, $options); - }// calculateWatermarkImageStartXY - - public function clear() { } - /** - * {@inheritDoc} - */ - public function convertAlpha127ToRgba($number) - { - return parent::convertAlpha127ToRgba($number); - }// convertAlpha127ToRgba - - public function crop($width, $height, $start_x = '0', $start_y = '0', $fill = 'transparent') { }