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

DocPropsCore   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 67
ccs 0
cts 32
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 61 2
1
<?php
2
3
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
4
5
use PhpOffice\Common\XMLWriter;
6
7
class DocPropsCore 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
        // cp:coreProperties
21
        $objWriter->startElement('cp:coreProperties');
22
        $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
23
        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
24
        $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
25
        $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
26
        $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
27
28
        // dc:creator
29
        $objWriter->writeElement('dc:creator', $this->oPresentation->getDocumentProperties()->getCreator());
30
31
        // cp:lastModifiedBy
32
        $objWriter->writeElement('cp:lastModifiedBy', $this->oPresentation->getDocumentProperties()->getLastModifiedBy());
33
34
        // dcterms:created
35
        $objWriter->startElement('dcterms:created');
36
        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
37
        $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getCreated()));
38
        $objWriter->endElement();
39
40
        // dcterms:modified
41
        $objWriter->startElement('dcterms:modified');
42
        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
43
        $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getModified()));
44
        $objWriter->endElement();
45
46
        // dc:title
47
        $objWriter->writeElement('dc:title', $this->oPresentation->getDocumentProperties()->getTitle());
48
49
        // dc:description
50
        $objWriter->writeElement('dc:description', $this->oPresentation->getDocumentProperties()->getDescription());
51
52
        // dc:subject
53
        $objWriter->writeElement('dc:subject', $this->oPresentation->getDocumentProperties()->getSubject());
54
55
        // cp:keywords
56
        $objWriter->writeElement('cp:keywords', $this->oPresentation->getDocumentProperties()->getKeywords());
57
58
        // cp:category
59
        $objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
60
61
        if ($this->oPresentation->getPresentationProperties()->isMarkedAsFinal()) {
62
            // cp:contentStatus = Final
63
            $objWriter->writeElement('cp:contentStatus', 'Final');
64
        }
65
66
        $objWriter->endElement();
67
68
        $this->oZip->addFromString('docProps/core.xml', $objWriter->getData());
69
70
        // Return
71
        return $this->oZip;
72
    }
73
}