Created
November 10, 2010 06:37
-
-
Save rocketeerbkw/670456 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 | |
// Legacy Code | |
class Foo { | |
public $some = 'thing'; | |
public $servers = array('server1', 'server2'); | |
} | |
// Refactored Foo | |
class Bar { | |
private $data = array( | |
'some' => 'thing', | |
'servers' => array('server1', 'server2'), | |
); | |
public function __get($var) { | |
return $this->data[$var]; | |
} | |
} | |
$foo = new Foo(); | |
echo print_r($foo->servers, true) . PHP_EOL; | |
$bar = new Bar(); | |
echo print_r($bar->servers, true) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment