Completed
Pull Request — develop (#187)
by Franck
08:38
created

DocPropsCustom::render()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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