Completed
Pull Request — develop (#186)
by
unknown
07:55
created

DocPropsCore   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

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