Created
November 30, 2010 13:08
-
-
Save avalanche123/721648 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 CheckingAccount extends BankAccount | |
{ | |
} | |
class SavingAccount extends BankAccount | |
{ | |
} |
This file contains hidden or 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 BankAccount | |
{ | |
public function debit($amount) | |
{ | |
//... | |
} | |
public function credit($amount) | |
{ | |
//... | |
} | |
} |
This file contains hidden or 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 | |
abstract class BankAccount | |
{ | |
abstract public function debit($amount); | |
abstract public function credit($amount); | |
} |
This file contains hidden or 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 | |
interface BankAccountInterface | |
{ | |
function credit($amount); | |
function debit($amount); | |
} | |
class BankAccount implements BankAccountInterface | |
{ | |
//... | |
} |
This file contains hidden or 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 PaymentGateway | |
{ | |
public function charge($amount, BankAccount $account) | |
{ | |
// make a call to http web service here... | |
$account->credit($amount) | |
} | |
} |
This file contains hidden or 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 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