From 7b76d797b86c691f39070fc9a51da08bf645e36b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 16 Mar 2024 14:11:43 +0000 Subject: [PATCH] code fixes --- Algorithm/Rating/Glicko1.php | 2 +- Algorithm/Rating/Glicko2.php | 2 +- Autoloader.php | 6 ++---- Business/Finance/Depreciation.php | 2 +- Business/Finance/DepreciationType.php | 2 +- Business/Finance/FinanceFormulas.php | 14 ++++++------- Business/Finance/Lorenzkurve.php | 4 ++-- Business/Marketing/Metrics.php | 20 +++++++++---------- Business/Marketing/NetPromoterScore.php | 2 +- Business/Marketing/PageRank.php | 2 +- .../ArticleCorrelationAffinity.php | 2 +- Business/Recommendation/ModelCF.php | 2 +- Business/Sales/MarketShareEstimation.php | 4 ++-- Dispatcher/Dispatcher.php | 4 ++-- Log/FileLogger.php | 8 ++++---- Math/Matrix/CholeskyDecomposition.php | 6 +++--- tests/Autoloader.php | 8 ++++++-- tests/Utils/PermutationTest.php | 4 ++-- 18 files changed, 48 insertions(+), 46 deletions(-) diff --git a/Algorithm/Rating/Glicko1.php b/Algorithm/Rating/Glicko1.php index 81652f4b2..0b2a6a8f0 100644 --- a/Algorithm/Rating/Glicko1.php +++ b/Algorithm/Rating/Glicko1.php @@ -102,7 +102,7 @@ final class Glicko1 } /** - * Calcualte the glicko-1 elo + * Calculate the glicko-1 elo * * @param int $elo Current player "elo" * @param int $rdOld Current player deviation (RD) diff --git a/Algorithm/Rating/Glicko2.php b/Algorithm/Rating/Glicko2.php index 171ee9687..15be92546 100644 --- a/Algorithm/Rating/Glicko2.php +++ b/Algorithm/Rating/Glicko2.php @@ -91,7 +91,7 @@ final class Glicko2 public int $MIN_RD = 50; /** - * Calcualte the glicko-2 elo + * Calculate the glicko-2 elo * * @example $glicko->elo(1500, 200, 0.06, [1,0,0], [1400,1550,1700], [30,100,300]) // 1464, 151, 0.059 * diff --git a/Autoloader.php b/Autoloader.php index 2cc707fdc..394d6c057 100755 --- a/Autoloader.php +++ b/Autoloader.php @@ -134,7 +134,6 @@ final class Autoloader */ public static function findPaths(string $class) : array { - $found = []; $class = \ltrim($class, '\\'); $class = \strtr($class, '_\\', '//'); @@ -143,12 +142,11 @@ final class Autoloader $subclass = $nspacePos === false ? '' : \substr($class, 0, $nspacePos); if (isset(self::$classmap[$subclass])) { - $found[] = self::$classmap[$subclass] . $class . '.php'; - - return $found; + return [self::$classmap[$subclass] . $class . '.php']; } } + $found = []; foreach (self::$paths as $path) { if (\is_file($file = $path . $class . '.php')) { $found[] = $file; diff --git a/Business/Finance/Depreciation.php b/Business/Finance/Depreciation.php index 4a2c4c7c4..fc5c32014 100755 --- a/Business/Finance/Depreciation.php +++ b/Business/Finance/Depreciation.php @@ -35,7 +35,7 @@ final class Depreciation } /** - * Calculate linear depretiation rate + * Calculate linear depreciation rate * * @param float $start Value to depreciate * @param int $duration Useful life time diff --git a/Business/Finance/DepreciationType.php b/Business/Finance/DepreciationType.php index 8e0d7c2c2..7f5874564 100644 --- a/Business/Finance/DepreciationType.php +++ b/Business/Finance/DepreciationType.php @@ -28,7 +28,7 @@ abstract class DepreciationType extends Enum { public const NONE = 1; - public const STAIGHT_LINE = 2; + public const STRAIGHT_LINE = 2; public const DECLINING_BALANCE = 3; diff --git a/Business/Finance/FinanceFormulas.php b/Business/Finance/FinanceFormulas.php index e1559078c..bca291015 100755 --- a/Business/Finance/FinanceFormulas.php +++ b/Business/Finance/FinanceFormulas.php @@ -127,7 +127,7 @@ final class FinanceFormulas /** * Annuity - Future Value w/ Continuous Compounding * - * @param float $cf Cach flow + * @param float $cf Cashflow * @param float $r Rate * @param int $t Time * @@ -143,7 +143,7 @@ final class FinanceFormulas /** * Annuity - Future Value w/ Continuous Compounding * - * @param float $fvacc Future value annuity continuous compoinding + * @param float $fvacc Future value annuity continuous compounding * @param float $r Rate * @param int $t Time * @@ -159,8 +159,8 @@ final class FinanceFormulas /** * Annuity - Future Value w/ Continuous Compounding * - * @param float $fvacc Future value annuity continuous compoinding - * @param float $cf Cach flow + * @param float $fvacc Future value annuity continuous compounding + * @param float $cf Cashflow * @param float $r Rate * * @return int @@ -766,7 +766,7 @@ final class FinanceFormulas } /** - * Get rate to dobule + * Get rate to double * * @param float $t Time in which to double investment * @@ -859,7 +859,7 @@ final class FinanceFormulas * Free Cash Flow to Equity (FCFE = FCFF - dept payments) * * @param float $income Net income - * @param float $depamo Depreciation & amortisation + * @param float $depamo Depreciation & amortization * @param float $capital Capital expenses * @param float $wc Change in working capital * @param float $borrowing Net Borrowing @@ -878,7 +878,7 @@ final class FinanceFormulas * * @param float $ebit EBIT * @param float $t Tax rate - * @param float $depamo Depreciation & amortisation + * @param float $depamo Depreciation & amortization * @param float $capital Capital expenses * @param float $wc Change in working capital * diff --git a/Business/Finance/Lorenzkurve.php b/Business/Finance/Lorenzkurve.php index c9ae30567..0ac0cf1f6 100755 --- a/Business/Finance/Lorenzkurve.php +++ b/Business/Finance/Lorenzkurve.php @@ -37,9 +37,9 @@ final class Lorenzkurve /** * Calculate Gini coefficient * - * @param array $data Datapoints (can be unsorted) + * @param array $data Data points (can be unsorted) * - * @return float Returns the gini coefficient + * @return float Returns the Gini coefficient * * @since 1.0.0 */ diff --git a/Business/Marketing/Metrics.php b/Business/Marketing/Metrics.php index d42fb077f..2511c4e82 100755 --- a/Business/Marketing/Metrics.php +++ b/Business/Marketing/Metrics.php @@ -59,7 +59,7 @@ final class Metrics } /** - * Calcualte the coefficient of retention + * Calculate the coefficient of retention * * @param float $retentionRate Observed retention rate (optionally use the average) * @param float $rc Retention rate ceiling @@ -109,13 +109,13 @@ final class Metrics /** * Calculate the customer profits * - * @param int $customers Amount of customers acquired - * @param float $acquistionCost Acquisition cost per customer - * @param float $revenue Revenues per period per customer - * @param float $cogs COGS per period per customer - * @param float $marketingCosts Ongoing marketing costs per period per customer - * @param float $discountRate Discount rate - * @param float $retentionRate Retention rate (how many customers remain) + * @param int $customers Amount of customers acquired + * @param float $acquisitionCost Acquisition cost per customer + * @param float $revenue Revenues per period per customer + * @param float $cogs COGS per period per customer + * @param float $marketingCosts Ongoing marketing costs per period per customer + * @param float $discountRate Discount rate + * @param float $retentionRate Retention rate (how many customers remain) * * @return float * @@ -123,7 +123,7 @@ final class Metrics */ public static function getBerrysCustomerProfits( int $customers, - float $acquistionCost, + float $acquisitionCost, float $revenue, float $cogs, float $marketingCosts, @@ -133,7 +133,7 @@ final class Metrics { return $customers * ($revenue - $cogs) * ((1 + $discountRate) / (1 + $discountRate - $retentionRate)) - $customers * $marketingCosts * ((1 + $discountRate) / (1 + $discountRate - $retentionRate)) - - $customers * $acquistionCost; + - $customers * $acquisitionCost; } /** diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 660111cc7..17635ffa7 100755 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -57,7 +57,7 @@ final class NetPromoterScore * * @latex NPS = Promoters - Detractors * - * @return int Retunrs the NPS + * @return int NPS * * @since 1.0.0 */ diff --git a/Business/Marketing/PageRank.php b/Business/Marketing/PageRank.php index 641649b8a..fde35ee14 100755 --- a/Business/Marketing/PageRank.php +++ b/Business/Marketing/PageRank.php @@ -95,7 +95,7 @@ final class PageRank } /** - * Calcualte the rank based on a start rank for the different elements + * Calculate the rank based on a start rank for the different elements * * A different start rank for different elements might make sense if the elements are not uniform from the very beginning * diff --git a/Business/Recommendation/ArticleCorrelationAffinity.php b/Business/Recommendation/ArticleCorrelationAffinity.php index 10340beef..bbe79adc8 100644 --- a/Business/Recommendation/ArticleCorrelationAffinity.php +++ b/Business/Recommendation/ArticleCorrelationAffinity.php @@ -39,7 +39,7 @@ final class ArticleCorrelationAffinity /** * Item order behavior (when are which items ordered) * - * In tearms of the pearson correlation these are our random variables + * In terms of the pearson correlation these are our random variables * * @var array * @since 1.0.0 diff --git a/Business/Recommendation/ModelCF.php b/Business/Recommendation/ModelCF.php index 8bdbf36e9..e268a302e 100644 --- a/Business/Recommendation/ModelCF.php +++ b/Business/Recommendation/ModelCF.php @@ -47,7 +47,7 @@ final class ModelCF * the item matrix contains in every row a score for how much it belongs to a certain attribute. Each column represents an item. * example: users columns define how much a user likes a certain movie genre and the item rows define how much this movie belongs to a certain genre. * the multiplication gives a score of how much the user may like that movie. - * A segnificant amount of attributes are required to calculate a good match + * A significant amount of attributes are required to calculate a good match * * @param array> $users A mxa matrix where each "m" defines how much the user likes a certain attribute type and "a" defines different users * @param array> $items A bxm matrix where each "b" defines a item and "m" defines how much it belongs to a certain attribute type diff --git a/Business/Sales/MarketShareEstimation.php b/Business/Sales/MarketShareEstimation.php index 84bef5fe0..34e8880d0 100755 --- a/Business/Sales/MarketShareEstimation.php +++ b/Business/Sales/MarketShareEstimation.php @@ -42,7 +42,7 @@ final class MarketShareEstimation * * @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}} * - * @param int $participants The amount of existing participants in the market or compentitors (N) + * @param int $participants The amount of existing participants in the market or competitors (N) * @param float $marketShare The absolute own market share (m) * @param float $modifier Distribution modifier (s) * @@ -65,7 +65,7 @@ final class MarketShareEstimation * * @latex m = \frac{\frac{1}{r^{s}}}{\sum_{n=1}^N{\frac{1}{n^{s}}}} * - * @param int $participants The amount of existing participants in the market or compentitors (N) + * @param int $participants The amount of existing participants in the market or competitors (N) * @param int $rank The absolute own rank in the market (r) * @param float $modifier Distribution modifier (s) * diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index c256b69ff..1c65a1fd9 100755 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -49,7 +49,7 @@ final class Dispatcher implements DispatcherInterface /** * Constructor. * - * @param ApplicationAbstract $app Appliaction + * @param ApplicationAbstract $app Application * * @since 1.0.0 */ @@ -78,7 +78,7 @@ final class Dispatcher implements DispatcherInterface } // Php void functions always return null. - // In a different language the Api functions would reguire a return type + // In a different language the Api functions would require a return type // If null is returned (i.e. void functions) these get ignored later in the response renderer as null is not "rendered" if (\is_string($controller)) { $views += $this->dispatchString($controller, $data); diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 09925c0e2..b35639d71 100755 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -369,7 +369,7 @@ final class FileLogger implements LoggerInterface } /** - * Analyse logging file. + * Analyze logging file. * * @return array * @@ -414,9 +414,9 @@ final class FileLogger implements LoggerInterface } /** - * Find cricitcal connections. + * Find critical connections. * - * @param int $limit Amout of perpetrators + * @param int $limit Amount of perpetrators * * @return array * @@ -464,7 +464,7 @@ final class FileLogger implements LoggerInterface /** * Get logging messages from file. * - * @param int $limit Amout of logs + * @param int $limit Amount of logs * @param int $offset Offset * * @return array diff --git a/Math/Matrix/CholeskyDecomposition.php b/Math/Matrix/CholeskyDecomposition.php index 32098ff5f..d872a5317 100755 --- a/Math/Matrix/CholeskyDecomposition.php +++ b/Math/Matrix/CholeskyDecomposition.php @@ -20,7 +20,7 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException; /** * Cholesky decomposition * - * A is syymetric, positive definite then A = L*L' + * A is symmetric, positive definite then A = L*L' * * @package phpOMS\Math\Matrix * @license OMS License 2.0 @@ -46,7 +46,7 @@ final class CholeskyDecomposition private int $m = 0; /** - * Is symmetric positiv definite + * Is symmetric positive definite * * @var bool * @since 1.0.0 @@ -89,7 +89,7 @@ final class CholeskyDecomposition } /** - * Is matrix symmetric positiv definite. + * Is matrix symmetric positive definite. * * @return bool * diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 95dd1b74c..89487804b 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -78,7 +78,9 @@ class Autoloader $class = \ltrim($class, '\\'); $class = \strtr($class, '_\\', '//'); - if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) { + if (\stripos($class, 'Web/Backend') !== false + || \stripos($class, 'Web/Api') !== false + ) { $class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class); } @@ -97,7 +99,9 @@ class Autoloader } foreach (self::$paths as $path) { - if (($file = \realpath($path . $class2 . '.php')) !== false && \stripos($file, $class3) !== false) { + if (($file = \realpath($path . $class2 . '.php')) !== false + && \stripos($file, $class3) !== false + ) { include_once $file; return; diff --git a/tests/Utils/PermutationTest.php b/tests/Utils/PermutationTest.php index ddf1f6599..b59391b55 100755 --- a/tests/Utils/PermutationTest.php +++ b/tests/Utils/PermutationTest.php @@ -30,7 +30,7 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase * @covers phpOMS\Utils\Permutation * @group framework */ - public function testPermute() : void + public function testPermuteAll() : void { $arr = ['a', 'b', 'c']; $permutations = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']; @@ -68,7 +68,7 @@ final class PermutationTest extends \PHPUnit\Framework\TestCase * @covers phpOMS\Utils\Permutation * @group framework */ - public function testPermute() : void + public function testPermuteBy() : void { self::assertEquals(['c', 'b', 'a'], Permutation::permuteByKey(['a', 'b', 'c'], [2, 1, 1])); }