From cafa70a7b68d8f8f3312f736e92faf6549592eab Mon Sep 17 00:00:00 2001 From: dashiwa Date: Thu, 31 Dec 2020 17:17:41 +0300 Subject: [PATCH] R-03 Creating methods for the first level of conditional expressions --- php/src/FirstProcessingRule.php | 41 ++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/php/src/FirstProcessingRule.php b/php/src/FirstProcessingRule.php index a275d121..6f9e5a69 100644 --- a/php/src/FirstProcessingRule.php +++ b/php/src/FirstProcessingRule.php @@ -19,24 +19,33 @@ class FirstProcessingRule $item = $this->item; if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') { - if ($item->quality > 0) { - if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->quality = $item->quality - 1; - } - } + $this->isNotAgedBrieBackstagePasses($item); } else { - if ($item->quality < 50) { - $item->quality = $item->quality + 1; - if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') { - if ($item->sell_in < 11) { - if ($item->quality < 50) { - $item->quality = $item->quality + 1; - } + $this->isAgedBrieBackstagePasses($item); + } + } + + public function isNotAgedBrieBackstagePasses(& $item){ + if ($item->quality > 0) { + if ($item->name != 'Sulfuras, Hand of Ragnaros') { + $item->quality = $item->quality - 1; + } + } + } + + public function isAgedBrieBackstagePasses(& $item) + { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; + if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') { + if ($item->sell_in < 11) { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; } - if ($item->sell_in < 6) { - if ($item->quality < 50) { - $item->quality = $item->quality + 1; - } + } + if ($item->sell_in < 6) { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; } } }