Completed
Pull Request — develop (#188)
by Franck
06:55
created

DocPropsCustom::render()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
ccs 16
cts 16
cp 1
rs 8.8571
cc 2
eloc 16
nc 2
nop 0
crap 2
1
<?php
2
3
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
4
5
use PhpOffice\Common\XMLWriter;
6
7
class DocPropsCustom extends AbstractDecoratorWriter
8
{
9
    /**
10
     * @return \PhpOffice\Common\Adapter\Zip\ZipInterface
11
     */
12 75
    public function render()
13
    {
14
        // Create XML writer
15 75
        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
16
17
        // XML header
18 75
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
19
20
        // Properties
21 75
        $objWriter->startElement('Properties');
22 75
        $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
23 75
        $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
24
25 75
        if ($this->getPresentation()->getPresentationProperties()->isMarkedAsFinal()) {
26
            // property
27 2
            $objWriter->startElement('property');
28 2
            $objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
29 2
            $objWriter->writeAttribute('pid', 2);
30 2
            $objWriter->writeAttribute('name', '_MarkAsFinal');
31
32
            // property > vt:bool
33 2
            $objWriter->writeElement('vt:bool', 'true');
34
35
            // > property
36 2
            $objWriter->endElement();
37
        }
38
39
        // > Properties
40 75
        $objWriter->endElement();
41
42 75
        $this->oZip->addFromString('docProps/custom.xml', $objWriter->getData());
43
44
        // Return
45 75
        return $this->oZip;
46
    }
47
}
48