From 1185341b557cf32010c4c21ab6b0dbdedf89c975 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 30 May 2019 20:54:53 +0200 Subject: [PATCH] moving constant arrays to a separate class --- src/Constants.php | 17 +++++++++++++++++ src/Tiebreaks.php | 23 ++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 src/Constants.php diff --git a/src/Constants.php b/src/Constants.php new file mode 100644 index 0000000..4fa0c64 --- /dev/null +++ b/src/Constants.php @@ -0,0 +1,17 @@ +getPairings() as $pairing) { - if (array_search($pairing->getResult(), self::Won) !== false) { + if (array_search($pairing->getResult(), Constants::Won) !== false) { $points = $points + 1; - } elseif (array_search($pairing->getResult(), self::Draw) !== false) { + } elseif (array_search($pairing->getResult(), Constants::Draw) !== false) { $points = $points + 0.5; } } @@ -63,7 +56,7 @@ abstract class Tiebreaks extends Tournament { $totalwins = 0; foreach ($player->getPairings() as $pairing) { - if (array_search($pairing->getResult(), self::Won) !== false) { + if (array_search($pairing->getResult(), Constants::Won) !== false) { $totalwins++; } } @@ -79,7 +72,7 @@ abstract class Tiebreaks extends Tournament { $totalwins = 0; foreach ($player->getPairings() as $pairing) { - if (array_search($pairing->getColor(), self::Black) !== false) { + if (array_search($pairing->getColor(), Constants::Black) !== false) { $totalwins++; } } @@ -94,7 +87,7 @@ abstract class Tiebreaks extends Tournament { $totalwins = 0; foreach ($player->getPairings() as $pairing) { - if (array_search($pairing->getColor(), self::Black) !== false && array_search($pairing->getResult(), Self::Won) !== false) { + if (array_search($pairing->getColor(), Constants::Black) !== false && array_search($pairing->getResult(), Constants::Won) !== false) { $totalwins++; } } @@ -123,9 +116,9 @@ abstract class Tiebreaks extends Tournament $totalmatches = 0; foreach ($player->getPairings() as $pairing) { if (array_search($pairing->getOpponent(), $interestingplayers) !== false) { - if (array_search($pairing->getResult(), self::Won) !== false) { + if (array_search($pairing->getResult(), Constants::Won) !== false) { $points = $points + 1; - } elseif (array_search($pairing->getResult(), self::Draw) !== false) { + } elseif (array_search($pairing->getResult(), Constants::Draw) !== false) { $points = $points + 0.5; } $totalmatches++; @@ -148,7 +141,7 @@ abstract class Tiebreaks extends Tournament $totalopponents = 0; $allratings = []; foreach ($pairings as $pairing) { - if (array_search($pairing->getResult(), self::NotPlayed) === false) { + if (array_search($pairing->getResult(), Constants::NotPlayed) === false) { $toadd = $pairing->getOpponent()->getElos()['home']; if ($toadd != 0) { $allratings[] = $toadd;