made some refactoring

This commit is contained in:
2025-07-09 05:28:39 +03:00
parent f76eb08fe0
commit 38676bc9fd
69 changed files with 3075 additions and 355 deletions

View File

@@ -0,0 +1,33 @@
<?php
/**
* @package: patterns
* @author: Yevhen Odynets
* @date: 2025-07-07
* @time: 05:28
*/
declare(strict_types = 1);
namespace Pattern\SOLID\OpenClosed\Figures;
class AreaCalculator
{
/**
* @param array $shapes
*
* @return int|float
*/
public function calculate(array $shapes, int $round_precision = 2): int|float
{
$area = [];
foreach ($shapes as $shape) {
$area[] = $shape->area();
}
$result = array_sum($area);
return is_int($result) ? $result : round($result, $round_precision, PHP_ROUND_HALF_UP);
}
}