Skip to content

Instantly share code, notes, and snippets.

@avalanche123
Created November 30, 2010 13:08
Show Gist options
  • Save avalanche123/721648 to your computer and use it in GitHub Desktop.
Save avalanche123/721648 to your computer and use it in GitHub Desktop.
<?php
class CheckingAccount extends BankAccount
{
}
class SavingAccount extends BankAccount
{
}
<?php
class BankAccount
{
public function debit($amount)
{
//...
}
public function credit($amount)
{
//...
}
}
<?php
abstract class BankAccount
{
abstract public function debit($amount);
abstract public function credit($amount);
}
<?php
interface BankAccountInterface
{
function credit($amount);
function debit($amount);
}
class BankAccount implements BankAccountInterface
{
//...
}
<?php
class PaymentGateway
{
public function charge($amount, BankAccount $account)
{
// make a call to http web service here...
$account->credit($amount)
}
}
<?php
class SomeAccount extends BankAccount
{
public function credit($amount, $someOtherParameter)
{
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment