Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created February 12, 2021 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobus1998/8107a1ce7bc974b0de124afd6e5c44d6 to your computer and use it in GitHub Desktop.
Save kobus1998/8107a1ce7bc974b0de124afd6e5c44d6 to your computer and use it in GitHub Desktop.
simple price calculation structure
<?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