<?php
require('includes/PhpWord/Autoloader.php');
\PhpOffice\PhpWord\Autoloader::register();

class DocumentHandler {
    private $documentID     = NULL;
    private $filename       = "";
    private $documentDraft  = "";
    private $documentHandle = NULL;

    public function __construct($filename, $draft) {
        $this->filename = $filename;
        $this->documentDraft = $draft;
        $this->documentHandle = new \PhpOffice\PhpWord\TemplateProcessor('drafts/' . $this->documentDraft);
    }

    public function getFilename() {
        return $this->filename;
    }

    public function saveFile() {
        $this->documentHandle->saveAs('documents/' . $this->filename);
    }

    public function getVariables() {
        return $this->documentHandle->getVariables();
    }

    public function setVal($key, $val) {
        $this->documentHandle->setValue($key, $val);
    }

}




?>
