Created
October 20, 2010 15:47
-
-
Save gcoop/636668 to your computer and use it in GitHub Desktop.
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 This | |
{ | |
private $data; // Actually protects data enforcing client code to write $obj->getData('foobar'); | |
public function getData($key) // public not needed, but lets be concise and obvious, code for idiots, simple as that because when you look back at your code in 6 months time you are that idiot! | |
{ | |
if (isset($this->data[$key])) // You will get a notice if you don't check before you do Coding rule #1, check before you presume. | |
return $this->data[$key]; | |
return null; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment