Skip to content

Instantly share code, notes, and snippets.

@genkovich
Last active April 13, 2021 18:23
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 genkovich/de5625b5746c3aae0a6e93ac653d6924 to your computer and use it in GitHub Desktop.
Save genkovich/de5625b5746c3aae0a6e93ac653d6924 to your computer and use it in GitHub Desktop.
<?php
class Customer
{
protected float $account = 0;
public function putMoneyIntoAccount(int|float $sum): void
{
if ($sum < 1) {
throw new Exception('Вы не можете положить на счёт меньше 1$');
}
$this->account += $sum;
}
}
class MicroCustomer extends Customer
{
public function putMoneyIntoAccount(int|float $sum): void
{
if ($sum < 1) {
throw new Exception('Вы не можете положить на счёт меньше 1$');
}
// Усиление предусловий
if ($sum > 100) {
throw new Exception('Вы не можете положить на больше 100$');
}
$this->account += $sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment