Code Duplication    Length = 19-20 lines in 2 locations

classes/PHPTAL/Context.php 2 locations

@@ 104-123 (lines=20) @@
101
     *
102
     * @return void
103
     */
104
    public function setDocType($doctype,$called_from_macro)
105
    {
106
        // FIXME: this is temporary workaround for problem of DOCTYPE disappearing in cloned PHPTAL object (because clone keeps _parentContext)
107
        if (!$this->_docType) {
108
            $this->_docType = $doctype;
109
        }
110
111
        if ($this->_parentContext) {
112
            $this->_parentContext->setDocType($doctype, $called_from_macro);
113
        } else if ($this->_echoDeclarations) {
114
            if (!$called_from_macro) {
115
                echo $doctype;
116
            } else {
117
                throw new PHPTAL_ConfigurationException("Executed macro in file with DOCTYPE when using echoExecute(). This is not supported yet. Remove DOCTYPE or use PHPTAL->execute().");
118
            }
119
        }
120
        else if (!$this->_docType) {
121
            $this->_docType = $doctype;
122
        }
123
    }
124
125
    /**
126
     * Set output document xml declaration.
@@ 136-154 (lines=19) @@
133
     *
134
     * @return void
135
     */
136
    public function setXmlDeclaration($xmldec, $called_from_macro)
137
    {
138
        // FIXME
139
        if (!$this->_xmlDeclaration) {
140
            $this->_xmlDeclaration = $xmldec;
141
        }
142
143
        if ($this->_parentContext) {
144
            $this->_parentContext->setXmlDeclaration($xmldec, $called_from_macro);
145
        } else if ($this->_echoDeclarations) {
146
            if (!$called_from_macro) {
147
                echo $xmldec."\n";
148
            } else {
149
                throw new PHPTAL_ConfigurationException("Executed macro in file with XML declaration when using echoExecute(). This is not supported yet. Remove XML declaration or use PHPTAL->execute().");
150
            }
151
        } else if (!$this->_xmlDeclaration) {
152
            $this->_xmlDeclaration = $xmldec;
153
        }
154
    }
155
156
    /**
157
     * Activate or deactivate exception throwing during unknown path