I have a rather large class XYZ which has a different behavior with different arguments given. Every argument shall have a helptext.
Since the class XYZ is very big, I want to encapsulate all argument-functions into an argumentManager class, and all help related functions into an helpManager class. This is possible since they have functions which are independent from XYZ. The result is like this:
<?php
class ArgumentManager {
    // DO NOT CALL
    public function addArgument($option, $argumentCount) {
        ...
    }
    // Other functions MAY be called by the user
    public function isArgumentInList($option) {
        ...
    }
    ...
}
class HelpManager {
    // DO NOT CALL
    public function addHelpEntry($option, $helptext) {
        ...
    }
    // Other functions MAY be called by the user
    public function printHelpPage() {
        ...
    }
    ...
}
class XYZ {
    private $helpManager;
    private $argumentManager;
    // The user may call everything in there, EXCEPT HelpManager::addHelpEntry, since it must be a created pair by XYZ::addArgumentWithHelp
    public function getHelpManager() {
        return $this->helpManager;
    }
    // The user may call everything in there, EXCEPT ArgumentManager::addArgument, since it must be a created pair by XYZ::addArgumentWithHelp
    public function getArgumentManager() {
        return $this->argumentManager;
    }
    // Create classes which contain independent functionalities
    public function __construct() {
        $this->helpManager = new HelpManager();
        $this->argumentManager = new ArgumentManager();
    }
    // Intended usage for creating an argument with help (they should always be a couple)
    public function addArgumentWithHelp($option, $helptext, $argumentCount) {
        $this->argumentManager->addArgument($option, $argumentCount);
        $this->helpManager->addHelpEntry($option, $helptext);
    }
    // Many other functions of the big class XYZ
    .....
}
The class XYZ is now much smaller.
An argument with helptext can be added by calling $XYZ->addArgumentWithHelp() .
Help related functions related functions can be called e.g. via $XYZ->getHelpManager()->printHelpPage() . The same goes for Argument related functions.
The problem is that I do not want that $XYZ->getHelpManager()->addHelpEntry() or $XYZ->getArgumentManager->addArgument() are called by anybody else except XYZ , since I want to enforce that both, the argumentManager and the helpManager have their informations about the option.
 
     
     
     
    