Created
February 12, 2021 14:33
-
-
Save kobus1998/8107a1ce7bc974b0de124afd6e5c44d6 to your computer and use it in GitHub Desktop.
simple price calculation structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Price | |
{ | |
public function getAmount(): int | |
{ | |
return 0; | |
} | |
} | |
class FirstPrice extends Price | |
{ | |
public function getAmount(): int | |
{ | |
return 1000; | |
} | |
} | |
class SecondPrice extends FirstPrice | |
{ | |
public function getAmount(): int | |
{ | |
return 2000 + parent::getAmount(); | |
} | |
} | |
class ThirdPrice extends SecondPrice | |
{ | |
public function getAmount(): int | |
{ | |
return 3000 + parent::getAmount(); | |
} | |
} | |
echo (new ThirdPrice)->getAmount() / 1000; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment