我有一個非常大的PHP類叫「播放器」。PHP>如何將一個類分成多個類?
裏面有很多功能(近2000行)。其實,我使用這些功能,以這樣的方式
$player = new Player(1)
echo $player->getLogin();
echo $player->getStatisticPerception();
echo $player->getWeaponId();
echo $player->attackPlayerId(3,$player->getWeaponId());
我認爲這可能是分裂這個類成倍數類是一個好主意,但我不知道怎麼辦。我怎麼能創造這樣,例如:
$player = new Player(1);
echo $player->getLogin();
echo $player->statistics->getAttack();
echo $player->stuff->getWeaponId();
echo $player->doAction->attackPlayerId(3, $player->getWeaponId());
如果認爲我要創建這個對象內部的對象,但如果我這樣做,我無法訪問的主要「玩家$」的對象數據(例如,在對象的東西,我不能選手對象的$級別的變量訪問。)