Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Initial scenario
- // (Just a very very simplified version for demonstration)
- class HelpManager {
- protected $entries;
- public function __construct() {
- $this->entries = array();
- }
- # DO NOT CALL
- public function _addEntry($entry) {
- $this->entries[] = $entry;
- }
- public function printHelp() {
- print_r($this->entries);
- }
- }
- class XYZ {
- protected $helpMan;
- public function __construct() {
- $this->helpMan = new HelpManager();
- }
- public function getHelpMan() {
- return $this->helpMan;
- }
- public function add($entry) {
- $this->helpMan->_addEntry($entry);
- }
- }
- $xyz = new XYZ();
- $xyz->add('test');
- $xyz->getHelpMan()->printHelp();
- $xyz->getHelpMan()->_addEntry('illegal');
- $xyz->getHelpMan()->printHelp();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement