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

DocPropsCustom   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 41
ccs 16
cts 16
cp 1
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
     * @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