Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,7 +24,7 @@ jobs:
node-version: '24.x'

- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.4']
php: ['8.5']

steps:
- name: Set up PHP
Expand All @@ -82,15 +82,15 @@ jobs:
node-version: '24.x'

- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Run Composer
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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions PHP_VERSIONS
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
8.1
8.2
8.3
8.4
8.5
8.4
8.3
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<table>
<tr>
<td><img src="examples/img/BoxplotDetmersReid2023_02.png" width ="300" /></td>
<td><img src="examples/img/BoxplotDetmersReid2023_01.png" width ="300" /></td>
<td><img src="examples/img/BoxplotNolanMcLean2025_02.png" width ="300" /></td>
<td><img src="examples/img/BoxplotNolanMcLean2025_01.png" width ="300" /></td>
</tr>
</table> 

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -525,15 +531,15 @@ You can set transparent background like this.

<a href="examples/img/TransparentBackground.png" target="_blank"><img src="examples/img/TransparentBackground.png" width="300" /></a>

- [DetmersReidBoxplot2023.php](examples/DetmersReidBoxplot2023.php) >> results in:
- [NolanMcLeanBoxplot2025.php](examples/NolanMcLeanBoxplot2025.php) >> results in:

<table>
<tr>
<td>
<a href="examples/img/BoxplotDetmersReid2023_01.png" target="_blank"><img src="examples/img/BoxplotDetmersReid2023_01.png" width="300" /></a>
<a href="examples/img/BoxplotNolanMcLean2025_01.png" target="_blank"><img src="examples/img/BoxplotNolanMcLean2025_01.png" width="300" /></a>
</td>
<td>
<a href="examples/img/BoxplotDetmersReid2023_02.png" target="_blank"><img src="examples/img/BoxplotDetmersReid2023_02.png" width="300" /></a>
<a href="examples/img/BoxplotNolanMcLean2025_02.png" target="_blank"><img src="examples/img/BoxplotNolanMcLean2025_02.png" width="300" /></a>
</td>
</tr>
</table>
Expand All @@ -545,7 +551,3 @@ You can set transparent background like this.
## License

[MIT](LICENSE)

***

Copyright 2023 - 2026 macocci7
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
16 changes: 0 additions & 16 deletions phpmd.xml

This file was deleted.

29 changes: 9 additions & 20 deletions src/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public function __construct()

/**
* loads config.
* @return void
*/
private function loadConf()
private function loadConf(): void
{
Config::load();
$props = [
Expand All @@ -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 = [];
Expand All @@ -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.");
Expand All @@ -96,10 +90,9 @@ public function limit(int|float $lower, int|float $upper)
/**
* sets data
* @param array<int|string, list<int|float>> $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<int|string, list<int|float>> expected.");
Expand All @@ -115,10 +108,9 @@ public function setData(array $data)
/**
* sets dataset
* @param array<int|string, array<int|string, array<int|string, int|float>>> $dataset
* @return self
* @thrown \Exception
*/
public function setDataset(array $dataset)
public function setDataset(array $dataset): self
{
if (!$this->isValidDataset($dataset)) {
throw new \Exception(
Expand All @@ -134,9 +126,8 @@ public function setDataset(array $dataset)
/**
* gets mean of $data
* @param array<int|string, int|float> $data
* @return float|null
*/
public function getMean(array $data)
public function getMean(array $data): ?float
{
if (!$this->isNumbersAll($data)) {
return null;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -178,7 +167,7 @@ public function getLcl()
* gets outliers
* @return list<int|float>|null
*/
public function getOutliers()
public function getOutliers(): ?array
{
if (!array_key_exists('data', $this->parsed)) {
return null;
Expand Down
6 changes: 2 additions & 4 deletions src/Boxplot.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public function __construct()

/**
* loads config.
* @return void
*/
private function loadConf()
private function loadConf(): void
{
Config::load();
$props = [
Expand All @@ -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;
Expand Down
23 changes: 7 additions & 16 deletions src/Helpers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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();
Expand All @@ -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)) {
Expand All @@ -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.");
Expand All @@ -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'];
Expand Down
Loading