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

DocPropsCustom   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 41
ccs 0
cts 19
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B render() 0 35 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
     *
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
}