How to divide long code into sections?

May 15, 2013 at 6:27 PM
My word document is usually 5 pages sometimes it is longer. When I create my word document my code gets messy. I am trying to divide my code into sections but it doesn't seem to work. This is what I am doing.ing.
public function createProposalDocument($p) {
        require (__INCLUDE__ . 'PHPWord.php');
        $PHPWord = new PHPWord();
        ... // Rest of the codes it is very long
        
        // Insert Descriptions
        $this->insertProposalDocumentDescription($PHPWord, $myStyle)

        // Insert Types
        $this->insertProposalDocumentTypes($PHPWord, $myStyle)
}
Now my word document consists of sections. I would like to separate these sections by calling them different methods as shown above. For example I have a Descriptions section in my word document, in the createProposalDocument($p) method I would like to call $this->insertProposalDocumentDescription($PHPWord) I tried to add $section but it didn't insert into the word document. Here is the code
private function insertProposalDocumentDescription(PHPWord $PHPWord, $style) {
        $PHPWord->addTitleStyle(1, $style['title'], array('spaceAfter' => 0));
        $section = $PHPWord->createSection();
        return $section->addTitle("DESCRIPTIONSECTION");
    }
Could you please tell me why this is not working? Thanks