diff --git a/php/src/AgedBrieCommand.php b/php/src/AgedBrieCommand.php new file mode 100644 index 00000000..8eba6f55 --- /dev/null +++ b/php/src/AgedBrieCommand.php @@ -0,0 +1,18 @@ +decreaseSellDate(); + + $item->increaseQuality(); + if ($item->isSellDatePassed()) { + $item->increaseQuality(); + } + } +} \ No newline at end of file diff --git a/php/src/BackstageCommand.php b/php/src/BackstageCommand.php new file mode 100644 index 00000000..836da3d8 --- /dev/null +++ b/php/src/BackstageCommand.php @@ -0,0 +1,27 @@ +decreaseSellDate(); + + if ($item->isSellDatePassed()) { + $item->quality = 0; + return; + } + + $item->increaseQuality(); + if ($item->sell_in <= 10) { + $item->increaseQuality(); + } + + if ($item->sell_in <= 5) { + $item->increaseQuality(); + } + } +} \ No newline at end of file diff --git a/php/src/Command.php b/php/src/Command.php new file mode 100644 index 00000000..99769748 --- /dev/null +++ b/php/src/Command.php @@ -0,0 +1,10 @@ +decreaseSellDate(); - - $item->increaseQuality(); - if ($item->isSellDatePassed()) { - $item->increaseQuality(); - } - } -} - -final class BackstageCommand implements Command -{ - public function execute(Item $item): void - { - $item->decreaseSellDate(); - - if ($item->isSellDatePassed()) { - $item->quality = 0; - return; - } - - $item->increaseQuality(); - if ($item->sell_in <= 10) { - $item->increaseQuality(); - } - - if ($item->sell_in <= 5) { - $item->increaseQuality(); - } - } -} - -final class NormalCommand implements Command -{ - public function execute(Item $item): void - { - $item->decreaseSellDate(); - $item->decreaseQuality(); - if ($item->isSellDatePassed()) { - $item->decreaseQuality(); - } - } -} - -final class NoopCommand implements Command -{ - public function execute(Item $item): void - { - // noop - } -} \ No newline at end of file diff --git a/php/src/NoopCommand.php b/php/src/NoopCommand.php new file mode 100644 index 00000000..2af4aa84 --- /dev/null +++ b/php/src/NoopCommand.php @@ -0,0 +1,13 @@ +decreaseSellDate(); + $item->decreaseQuality(); + if ($item->isSellDatePassed()) { + $item->decreaseQuality(); + } + } +} \ No newline at end of file