From 028b77c42fa490954894ad4d126cb617ee740a98 Mon Sep 17 00:00:00 2001 From: macocci7 Date: Thu, 9 Apr 2026 21:49:51 +0900 Subject: [PATCH] update --- .github/workflows/test_pull_request.yml | 10 +-- LICENSE | 2 +- PHP_VERSIONS | 6 +- README.md | 26 ++++---- composer.json | 6 +- phpmd.xml | 16 ----- src/Analyzer.php | 29 +++------ src/Boxplot.php | 6 +- src/Helpers/Config.php | 23 ++----- src/Plotter.php | 87 +++++++------------------ src/Traits/AttributeTrait.php | 23 ++----- src/Traits/JudgeTrait.php | 22 ++----- src/Traits/StyleTrait.php | 41 +++--------- src/Traits/VisibilityTrait.php | 30 +++------ tests/AnalyzerTest.php | 12 ++-- tests/Helpers/ConfigTest.php | 7 +- tests/Traits/JudgeTraitTest.php | 6 +- 17 files changed, 102 insertions(+), 250 deletions(-) delete mode 100644 phpmd.xml diff --git a/.github/workflows/test_pull_request.yml b/.github/workflows/test_pull_request.yml index cafbcc9..b5cfebc 100644 --- a/.github/workflows/test_pull_request.yml +++ b/.github/workflows/test_pull_request.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['8.3', '8.4', '8.5'] steps: - name: Set up PHP @@ -24,7 +24,7 @@ jobs: node-version: '24.x' - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.4'] + php: ['8.5'] steps: - name: Set up PHP @@ -82,7 +82,7 @@ jobs: node-version: '24.x' - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -90,7 +90,7 @@ jobs: run: composer install --no-interaction - name: Update PHPUnit for Code Coverage - run: composer require phpunit/phpunit:^10.5 sebastian/version:* --with-all-dependencies + run: composer require phpunit/phpunit:^12.5 sebastian/version:* --with-all-dependencies - name: PHP Lint run: ./vendor/bin/parallel-lint src tests examples diff --git a/LICENSE b/LICENSE index 36a3822..32aa312 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 macocci7 +Copyright (c) 2023-present macocci7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PHP_VERSIONS b/PHP_VERSIONS index 0f39030..025c143 100644 --- a/PHP_VERSIONS +++ b/PHP_VERSIONS @@ -1,5 +1,3 @@ -8.1 -8.2 -8.3 -8.4 8.5 +8.4 +8.3 diff --git a/README.md b/README.md index 0c8e95f..cf11cf2 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ - - + +
  @@ -43,14 +43,20 @@ Transparent background is also supported. ## 3. Requirements -- PHP 8.1 or later +- PHP 8.3 or later - Imagick PHP Extension Check with commands: ```bash - php -i | grep imagick + (php -m; php -i) | grep imagick ``` -- Composer +- Mbstring PHP Extension + + Check with commands: + ```bash + (php -m; php -i) | grep mbstring + ``` +- [Composer](https://getcomposer.org/) ## 4. Installation @@ -525,15 +531,15 @@ You can set transparent background like this. -- [DetmersReidBoxplot2023.php](examples/DetmersReidBoxplot2023.php) >> results in: +- [NolanMcLeanBoxplot2025.php](examples/NolanMcLeanBoxplot2025.php) >> results in:
- + - +
@@ -545,7 +551,3 @@ You can set transparent background like this. ## License [MIT](LICENSE) - -*** - -Copyright 2023 - 2026 macocci7 diff --git a/composer.json b/composer.json index 3b80d8a..e6d0c68 100644 --- a/composer.json +++ b/composer.json @@ -3,15 +3,15 @@ "description": "PHP-Boxplot creates boxplots using FrequencyTable.", "type": "library", "require": { - "php": ">=8.1", + "php": ">=8.3", "macocci7/php-frequency-table": "^1.4", "fakerphp/faker": "^1.24", "nette/neon": "^3.4", - "macocci7/php-plotter2d": "^0.4" + "macocci7/php-plotter2d": "^1.0" }, "require-dev": { "squizlabs/php_codesniffer": "^4.0", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^12.5", "phpstan/phpstan": "^2.1", "php-parallel-lint/php-parallel-lint": "^1.4" }, diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index bc07190..0000000 --- a/phpmd.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - Custom ruleset PHPMD - - - - - - - - - - - - - diff --git a/src/Analyzer.php b/src/Analyzer.php index 37039a7..be58fbf 100644 --- a/src/Analyzer.php +++ b/src/Analyzer.php @@ -41,9 +41,8 @@ public function __construct() /** * loads config. - * @return void */ - private function loadConf() + private function loadConf(): void { Config::load(); $props = [ @@ -58,10 +57,8 @@ private function loadConf() * returns prop: * - of the specified key * - all configs if param is not specified - * @param string|null $key = null - * @return mixed */ - public function getProp(string|null $key = null) + public function getProp(string|null $key = null): mixed { if (is_null($key)) { $config = []; @@ -78,12 +75,9 @@ public function getProp(string|null $key = null) /** * sets lower limit and upper limit - * @param int|float $lower - * @param int|float $upper - * @return self * @thrown \Exception */ - public function limit(int|float $lower, int|float $upper) + public function limit(int|float $lower, int|float $upper): self { if ($lower >= $upper) { throw new \Exception("lower limit must be less than upper limit."); @@ -96,10 +90,9 @@ public function limit(int|float $lower, int|float $upper) /** * sets data * @param array> $data - * @return self * @thrown \Exception */ - public function setData(array $data) + public function setData(array $data): self { if (!$this->isValidData($data)) { throw new \Exception("Invalid data specified. array> expected."); @@ -115,10 +108,9 @@ public function setData(array $data) /** * sets dataset * @param array>> $dataset - * @return self * @thrown \Exception */ - public function setDataset(array $dataset) + public function setDataset(array $dataset): self { if (!$this->isValidDataset($dataset)) { throw new \Exception( @@ -134,9 +126,8 @@ public function setDataset(array $dataset) /** * gets mean of $data * @param array $data - * @return float|null */ - public function getMean(array $data) + public function getMean(array $data): ?float { if (!$this->isNumbersAll($data)) { return null; @@ -146,9 +137,8 @@ public function getMean(array $data) /** * gets UCL - * @return float|null */ - public function getUcl() + public function getUcl(): ?float { if (!array_key_exists('ThirdQuartile', $this->parsed)) { return null; @@ -161,9 +151,8 @@ public function getUcl() /** * gets LCL - * @return float|null */ - public function getLcl() + public function getLcl(): ?float { if (!array_key_exists('FirstQuartile', $this->parsed)) { return null; @@ -178,7 +167,7 @@ public function getLcl() * gets outliers * @return list|null */ - public function getOutliers() + public function getOutliers(): ?array { if (!array_key_exists('data', $this->parsed)) { return null; diff --git a/src/Boxplot.php b/src/Boxplot.php index cb67907..6cb2486 100644 --- a/src/Boxplot.php +++ b/src/Boxplot.php @@ -26,9 +26,8 @@ public function __construct() /** * loads config. - * @return void */ - private function loadConf() + private function loadConf(): void { Config::load(); $props = [ @@ -43,9 +42,8 @@ private function loadConf() /** * set config from specified resource * @param string|mixed[] $configResource - * @return self */ - public function config(string|array $configResource) + public function config(string|array $configResource): self { foreach (Config::filter($configResource) as $key => $value) { $this->{$key} = $value; diff --git a/src/Helpers/Config.php b/src/Helpers/Config.php index b2cfbc8..58312cd 100644 --- a/src/Helpers/Config.php +++ b/src/Helpers/Config.php @@ -21,9 +21,8 @@ class Config /** * loads config from a file - * @return void */ - public static function load() + public static function load(): void { $class = self::class(); $cl = self::className($class); @@ -33,19 +32,16 @@ public static function load() /** * returns the fully qualified class name of the caller - * @return string */ - public static function class() + public static function class(): string { return debug_backtrace()[2]['class']; } /** * returns just the class name splitted parent namespace - * @param string $class - * @return string */ - public static function className(string $class) + public static function className(string $class): string { $pos = strrpos($class, '\\'); if ($pos) { @@ -56,10 +52,8 @@ public static function className(string $class) /** * returns config data - * @param string $key = null - * @return mixed */ - public static function get(?string $key = null) + public static function get(?string $key = null): mixed { // get fully qualified class name of the caller $class = self::class(); @@ -85,7 +79,7 @@ public static function get(?string $key = null) * @param string|mixed[] $configResource * @return mixed[] */ - public static function filter(string|array $configResource) + public static function filter(string|array $configResource): array { $class = self::class(); if (is_string($configResource)) { @@ -96,12 +90,10 @@ public static function filter(string|array $configResource) /** * returns valid config items from specified file - * @param string $path - * @param string $class * @return mixed[] * @thrown \Exception */ - private static function filterFromFile(string $path, string $class) + private static function filterFromFile(string $path, string $class): array { if (strlen($path) === 0) { throw new \Exception("Specify valid filename."); @@ -116,11 +108,10 @@ private static function filterFromFile(string $path, string $class) /** * returns valid config items from specified array * @param mixed[] $content - * @param string $class * @return mixed[] * @thrown \Exception */ - private static function filterFromArray(array $content, string $class) + private static function filterFromArray(array $content, string $class): array { $conf = []; $validConfig = self::$conf[$class]['validConfig']; diff --git a/src/Plotter.php b/src/Plotter.php index 8b873f1..34f21db 100644 --- a/src/Plotter.php +++ b/src/Plotter.php @@ -58,9 +58,8 @@ public function __construct() /** * loads config. - * @return void */ - private function loadConf() + private function loadConf(): void { Config::load(); foreach (array_keys(Config::get('validConfig')) as $prop) { @@ -70,9 +69,8 @@ private function loadConf() /** * sets properties - * @return self */ - private function setProperties() + private function setProperties(): self { $this->legendCount = count($this->dataSet); if (!$this->boxBackgroundColors) { @@ -178,8 +176,6 @@ private function setDefaultPlotarea(): void /** * adjusts gridHeightPitch - * - * @param float $gridHeightSpan */ private function adjustGridHeightPitch(float $gridHeightSpan): void { @@ -219,9 +215,8 @@ private function createCanvas(): void /** * plots axis - * @return self */ - private function plotAxis() + private function plotAxis(): self { if (!$this->showAxis) { return $this; @@ -257,9 +252,8 @@ private function plotAxis() /** * plots grids - * @return self */ - private function plotGrids() + private function plotGrids(): self { $this->plotGridHorizontal(); $this->plotGridVertical(); @@ -268,9 +262,8 @@ private function plotGrids() /** * plots horizontal grids - * @return self */ - private function plotGridHorizontal() + private function plotGridHorizontal(): self { [$offsetX, $offsetY] = $this->plotarea['offset']; for ($y = $this->gridMin; $y <= $this->gridMax; $y += $this->gridHeightPitch) { @@ -292,9 +285,8 @@ private function plotGridHorizontal() /** * plots vertical grid - * @return self */ - private function plotGridVertical() + private function plotGridVertical(): self { if (!$this->gridVertical) { return $this; @@ -321,9 +313,8 @@ private function plotGridVertical() /** * plots grid values - * @return self */ - private function plotGridValues() + private function plotGridValues(): self { [$offsetX, $offsetY] = $this->plotarea['offset']; for ($y = $this->gridMin; $y <= $this->gridMax; $y += $this->gridHeightPitch) { @@ -344,11 +335,8 @@ private function plotGridValues() /** * plots a box - * @param int $index - * @param int $legend - * @return self */ - private function plotBox(int $index, int $legend) + private function plotBox(int $index, int $legend): self { [$offsetX, $offsetY] = $this->plotarea['offset']; $rateX = $this->transformer->getRateX(); @@ -373,11 +361,8 @@ private function plotBox(int $index, int $legend) /** * plots meadian - * @param int $index - * @param int $legend - * @return self */ - private function plotMedian(int $index, int $legend) + private function plotMedian(int $index, int $legend): self { [$offsetX, $offsetY] = $this->plotarea['offset']; $legends = $this->legendCount; @@ -401,11 +386,8 @@ private function plotMedian(int $index, int $legend) /** * plots mean - * @param int $index - * @param int $legend - * @return self */ - private function plotMean(int $index, int $legend) + private function plotMean(int $index, int $legend): self { if (!$this->mean) { return $this; @@ -433,11 +415,8 @@ private function plotMean(int $index, int $legend) /** * plot an upper whisker - * @param int $index - * @param int $legend - * @return self */ - private function plotWhiskerUpper(int $index, int $legend) + private function plotWhiskerUpper(int $index, int $legend): self { // upper whisker [$offsetX, $offsetY] = $this->plotarea['offset']; @@ -489,11 +468,8 @@ private function plotWhiskerUpper(int $index, int $legend) /** * plots a lower whisker - * @param int $index - * @param int $legend - * @return self */ - private function plotWhiskerLower(int $index, int $legend) + private function plotWhiskerLower(int $index, int $legend): self { // lower whisker [$offsetX, $offsetY] = $this->plotarea['offset']; @@ -545,11 +521,8 @@ private function plotWhiskerLower(int $index, int $legend) /** * plots whiskers - * @param int $index - * @param int $legend - * @return self */ - private function plotWhisker(int $index, int $legend) + private function plotWhisker(int $index, int $legend): self { $this->plotWhiskerUpper($index, $legend); $this->plotWhiskerLower($index, $legend); @@ -558,11 +531,8 @@ private function plotWhisker(int $index, int $legend) /** * plots outliers - * @param int $index - * @param int $legend - * @return self */ - private function plotOutliers(int $index, int $legend) + private function plotOutliers(int $index, int $legend): self { if (!$this->outlier) { return $this; @@ -589,11 +559,8 @@ private function plotOutliers(int $index, int $legend) /** * plots jitter - * @param int $index - * @param int $legend - * @return self */ - private function plotJitter(int $index, int $legend) + private function plotJitter(int $index, int $legend): self { if (!$this->jitter) { return $this; @@ -630,9 +597,8 @@ private function plotJitter(int $index, int $legend) /** * plots labels - * @return self */ - private function plotLabels() + private function plotLabels(): self { if (empty($this->labels)) { return $this; @@ -663,9 +629,8 @@ private function plotLabels() /** * plots label of X - * @return self */ - private function plotLabelX() + private function plotLabelX(): self { $coord = $this->transformer->getCoord(0, 0); $offset = $this->plotarea['offset']; @@ -687,9 +652,8 @@ private function plotLabelX() /** * plots label of Y - * @return self */ - private function plotLabelY() + private function plotLabelY(): self { $width = $this->canvasHeight; $height = (int) ($this->canvasWidth * (1 - $this->frameXRatio) / 3); @@ -713,9 +677,8 @@ private function plotLabelY() /** * plots caption - * @return self */ - private function plotCaption() + private function plotCaption(): self { $x = (int) ($this->canvasWidth / 2); $y = (int) ($this->canvasHeight * (1 - $this->frameYRatio) / 3); @@ -734,9 +697,8 @@ private function plotCaption() /** * plots a legend - * @return self */ - private function plotLegend() + private function plotLegend(): self { if (!$this->legend) { return $this; @@ -793,11 +755,8 @@ private function plotLegend() /** * plots stuffs - * @param int $index - * @param int $legend - * @return self */ - private function plot(int $index, int $legend) + private function plot(int $index, int $legend): self { $this->plotBox($index, $legend); $this->plotMedian($index, $legend); @@ -810,11 +769,9 @@ private function plot(int $index, int $legend) /** * creates boxplots - * @param string $filePath - * @return self * @thrown \Exception */ - public function create(string $filePath) + public function create(string $filePath): self { if (strlen($filePath) === 0) { throw new \Exception("empty string specified for file path."); diff --git a/src/Traits/AttributeTrait.php b/src/Traits/AttributeTrait.php index fcd542b..caa745c 100644 --- a/src/Traits/AttributeTrait.php +++ b/src/Traits/AttributeTrait.php @@ -18,12 +18,9 @@ trait AttributeTrait /** * resizes width and height - * @param int $width - * @param int $height - * @return self * @thrown \Exception */ - public function resize(int $width, int $height) + public function resize(int $width, int $height): self { if ($width < $this->CANVAS_WIDTH_LIMIT_LOWER) { throw new \Exception( @@ -45,9 +42,8 @@ public function resize(int $width, int $height) /** * sets labels * @param array $labels - * @return self */ - public function labels(array $labels) + public function labels(array $labels): self { $this->labels = []; foreach ($labels as $label) { @@ -58,10 +54,8 @@ public function labels(array $labels) /** * sets the label of X - * @param string $label - * @return self */ - public function labelX(string $label) + public function labelX(string $label): self { $this->labelX = $label; return $this; @@ -69,10 +63,8 @@ public function labelX(string $label) /** * sets the label of Y - * @param string $label - * @return self */ - public function labelY(string $label) + public function labelY(string $label): self { $this->labelY = $label; return $this; @@ -80,10 +72,8 @@ public function labelY(string $label) /** * sets the caption - * @param string $caption - * @return self */ - public function caption(string $caption) + public function caption(string $caption): self { $this->caption = $caption; return $this; @@ -92,9 +82,8 @@ public function caption(string $caption) /** * sets legends * @param string[] $legends - * @return self */ - public function legends(array $legends) + public function legends(array $legends): self { $this->legends = $legends; return $this; diff --git a/src/Traits/JudgeTrait.php b/src/Traits/JudgeTrait.php index bba0dbe..878a2d0 100644 --- a/src/Traits/JudgeTrait.php +++ b/src/Traits/JudgeTrait.php @@ -7,7 +7,6 @@ trait JudgeTrait /** * judges if all items are integer or not * @param array $items - * @return bool */ public static function isIntAll(array $items): bool { @@ -25,7 +24,6 @@ public static function isIntAll(array $items): bool /** * judges if the param is number * @param mixed $item - * @return bool */ public static function isNumber(mixed $item): bool { @@ -34,8 +32,6 @@ public static function isNumber(mixed $item): bool /** * judges if all items are number or not - * @param mixed $items - * @return bool */ public static function isNumbersAll(mixed $items): bool { @@ -55,8 +51,6 @@ public static function isNumbersAll(mixed $items): bool /** * judges if the param is in '#rrggbb' format or not - * @param mixed $item - * @return bool */ public static function isColorCode(mixed $item): bool { @@ -69,9 +63,8 @@ public static function isColorCode(mixed $item): bool /** * judges if all of params are colorcode or not * @param string[] $colors - * @return bool */ - public static function isColorCodeAll(array $colors) + public static function isColorCodeAll(array $colors): bool { if (empty($colors)) { return false; @@ -86,11 +79,8 @@ public static function isColorCodeAll(array $colors) /** * judges if type of $input is valid or not - * @param mixed $input - * @param string $defs - * @return bool */ - public static function isValidType(mixed $input, string $defs) + public static function isValidType(mixed $input, string $defs): bool { $r = false; foreach (explode('|', $defs) as $def) { @@ -111,10 +101,8 @@ public static function isValidType(mixed $input, string $defs) /** * judges if the data is valid or not - * @param mixed $data - * @return bool */ - public static function isValidData(mixed $data) + public static function isValidData(mixed $data): bool { if (!is_array($data)) { return false; @@ -132,10 +120,8 @@ public static function isValidData(mixed $data) /** * judges if the dataset is valid or not - * @param mixed $dataset - * @return bool */ - public static function isValidDataset(mixed $dataset) + public static function isValidDataset(mixed $dataset): bool { if (!is_array($dataset)) { return false; diff --git a/src/Traits/StyleTrait.php b/src/Traits/StyleTrait.php index 52da52f..1c3f80f 100644 --- a/src/Traits/StyleTrait.php +++ b/src/Traits/StyleTrait.php @@ -35,10 +35,8 @@ trait StyleTrait /** * sets canvas background color - * @param string $bgcolor - * @return self */ - public function bgcolor(string $bgcolor) + public function bgcolor(string $bgcolor): self { if (!$this->isColorCode($bgcolor)) { throw new \Exception("specify rgb color code."); @@ -49,10 +47,8 @@ public function bgcolor(string $bgcolor) /** * sets font color - * @param string $color - * @return self */ - public function fontColor(string $color) + public function fontColor(string $color): self { if (!$this->isColorCode($color)) { throw new \Exception("specify rgb color code."); @@ -63,10 +59,8 @@ public function fontColor(string $color) /** * sets axis color - * @param string $color - * @return self */ - public function axisColor(string $color) + public function axisColor(string $color): self { if (!$this->isColorCode($color)) { throw new \Exception("specify rgb color code."); @@ -77,10 +71,8 @@ public function axisColor(string $color) /** * sets grid color - * @param string $color - * @return self */ - public function gridColor(string $color) + public function gridColor(string $color): self { if (!$this->isColorCode($color)) { throw new \Exception("specify rgb color code."); @@ -91,10 +83,8 @@ public function gridColor(string $color) /** * sets legend background color - * @param string $color - * @return self */ - public function legendBgcolor(string $color) + public function legendBgcolor(string $color): self { if (!$this->isColorCode($color)) { throw new \Exception("specify rgb color code."); @@ -105,11 +95,8 @@ public function legendBgcolor(string $color) /** * sets attributes of border of boxes - * @param int $width - * @param string $color - * @return self */ - public function boxBorder(int $width, string $color) + public function boxBorder(int $width, string $color): self { if ($width < 1) { throw new \Exception("specify natural number as width."); @@ -124,11 +111,8 @@ public function boxBorder(int $width, string $color) /** * sets attributes of whisker - * @param int $width - * @param string $color - * @return self */ - public function whisker(int $width, string $color) + public function whisker(int $width, string $color): self { if ($width < 1) { throw new \Exception("specify natural number as width."); @@ -143,10 +127,8 @@ public function whisker(int $width, string $color) /** * sets height pitch of grid - * @param int|float $pitch - * @return self */ - public function gridHeightPitch(int|float $pitch) + public function gridHeightPitch(int|float $pitch): self { if ($pitch <= 0) { throw new \Exception("specify positive number."); @@ -157,10 +139,8 @@ public function gridHeightPitch(int|float $pitch) /** * sets width of boxes - * @param int $width - * @return self */ - public function boxWidth(int $width) + public function boxWidth(int $width): self { if ($width < $this->boxBorderWidth * 2 + 1) { throw new \Exception("Box width must be greater than twice of box border width."); @@ -172,9 +152,8 @@ public function boxWidth(int $width) /** * sets background colors of boxes * @param string[] $colors - * @return self */ - public function boxBackground(array $colors) + public function boxBackground(array $colors): self { if (!$this->isColorCodeAll($colors)) { throw new \Exception("only color codes are acceptable."); diff --git a/src/Traits/VisibilityTrait.php b/src/Traits/VisibilityTrait.php index 71b1451..72ba4ff 100644 --- a/src/Traits/VisibilityTrait.php +++ b/src/Traits/VisibilityTrait.php @@ -13,9 +13,8 @@ trait VisibilityTrait /** * sets vertical grids on - * @return self */ - public function gridVerticalOn() + public function gridVerticalOn(): self { $this->gridVertical = true; return $this; @@ -23,9 +22,8 @@ public function gridVerticalOn() /** * sets vertical grids off - * @return self */ - public function gridVerticalOff() + public function gridVerticalOff(): self { $this->gridVertical = false; return $this; @@ -33,9 +31,8 @@ public function gridVerticalOff() /** * sets detecting outliers on - * @return self */ - public function outlierOn() + public function outlierOn(): self { $this->outlier = true; return $this; @@ -43,9 +40,8 @@ public function outlierOn() /** * sets detecting outliers off - * @return self */ - public function outlierOff() + public function outlierOff(): self { $this->outlier = false; return $this; @@ -53,9 +49,8 @@ public function outlierOff() /** * sets jitter plotting on - * @return self */ - public function jitterOn() + public function jitterOn(): self { $this->jitter = true; return $this; @@ -63,9 +58,8 @@ public function jitterOn() /** * sets jitter plotting off - * @return self */ - public function jitterOff() + public function jitterOff(): self { $this->jitter = false; return $this; @@ -73,9 +67,8 @@ public function jitterOff() /** * sets plotting means on - * @return self */ - public function meanOn() + public function meanOn(): self { $this->mean = true; return $this; @@ -83,9 +76,8 @@ public function meanOn() /** * sets plotting means off - * @return self */ - public function meanOff() + public function meanOff(): self { $this->mean = false; return $this; @@ -93,9 +85,8 @@ public function meanOff() /** * sets showing legends on - * @return self */ - public function legendOn() + public function legendOn(): self { $this->legend = true; return $this; @@ -103,9 +94,8 @@ public function legendOn() /** * sets showing legends off - * @return self */ - public function legendOff() + public function legendOff(): self { $this->legend = false; return $this; diff --git a/tests/AnalyzerTest.php b/tests/AnalyzerTest.php index 557d276..7481121 100644 --- a/tests/AnalyzerTest.php +++ b/tests/AnalyzerTest.php @@ -2,16 +2,12 @@ declare(strict_types=1); -namespace Macocci7\PhpBoxplot; +namespace Macocci7\PhpBoxplot\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Analyzer; -/** - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.CamelCaseMethodName) - */ final class AnalyzerTest extends TestCase { public static function provide_limit_throw_exception_with_invalid_params(): array @@ -59,7 +55,7 @@ public static function provide_getMean_can_get_mean_correctly(): array ['data' => [null], 'expect' => null, ], ['data' => [true], 'expect' => null, ], ['data' => [false], 'expect' => null, ], - ['data' => [0], 'expect' => 0, ], + ['data' => [0], 'expect' => 0.0, ], ['data' => [1.2], 'expect' => 1.2, ], ['data' => ['0'], 'expect' => null, ], ['data' => ['1.2'], 'expect' => null, ], @@ -73,8 +69,8 @@ public static function provide_getMean_can_get_mean_correctly(): array #[DataProvider('provide_getMean_can_get_mean_correctly')] public function test_getMean_can_get_mean_correctly(array $data, int|float|null $expect): void { - $bp = new Boxplot(); - $this->assertSame($expect, $bp->getMean($data)); + $a = new Analyzer(); + $this->assertSame($expect, $a->getMean($data)); } public static function provide_getUcl_can_get_ucl_correctly(): array diff --git a/tests/Helpers/ConfigTest.php b/tests/Helpers/ConfigTest.php index 3c6558b..9b1feaf 100644 --- a/tests/Helpers/ConfigTest.php +++ b/tests/Helpers/ConfigTest.php @@ -2,16 +2,13 @@ declare(strict_types=1); -namespace Macocci7\PhpBoplot\Helpers; +namespace Macocci7\PhpBoxplot\Tests\Helpers; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Helpers\Config; use Nette\Neon\Neon; -/** - * @SuppressWarnings(PHPMD.CamelCaseMethodName) - */ final class ConfigTest extends TestCase { // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps @@ -51,7 +48,7 @@ public function test_class_can_return_class_name_correctly(): void public static function provide_className_can_return_class_name_correctly(): array { return [ - "Fully Qualified" => [ 'class' => '\Macocci7\PhpHistogram\Helper\ConfigTest', 'expect' => 'ConfigTest', ], + "Fully Qualified" => [ 'class' => '\Macocci7\PhpBoxplot\Helper\ConfigTest', 'expect' => 'ConfigTest', ], "Relative" => [ 'class' => 'Helper\ConfigTest', 'expect' => 'ConfigTest', ], "Only Class Name" => [ 'class' => 'ConfigTest', 'expect' => 'ConfigTest', ], ]; diff --git a/tests/Traits/JudgeTraitTest.php b/tests/Traits/JudgeTraitTest.php index 0dd3709..5ecc15d 100644 --- a/tests/Traits/JudgeTraitTest.php +++ b/tests/Traits/JudgeTraitTest.php @@ -2,17 +2,13 @@ declare(strict_types=1); -namespace Macocci7\PhpBoxplot\Traits; +namespace Macocci7\PhpBoxplot\Tests\Traits; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Traits\JudgeTrait; use Nette\Neon\Neon; -/** - * @SuppressWarnings(PHPMD.TooManyPublicMethods) - * @SuppressWarnings(PHPMD.CamelCaseMethodName) - */ final class JudgeTraitTest extends TestCase { use JudgeTrait;