Completed
Pull Request — develop (#565)
by
unknown
06:14
created

DocPropsCore   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 96.55%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 68
ccs 28
cts 29
cp 0.9655
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B 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
     * @return \PhpOffice\Common\Adapter\Zip\ZipInterface
11
     * @throws \Exception
12
     */
13 5
    public function render()
14
    {
15
        // Create XML writer
16 5
        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
17
18
        // XML header
19 5
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
20
21
        // cp:coreProperties
22 5
        $objWriter->startElement('cp:coreProperties');
23 5
        $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
24 5
        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
25 5
        $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
26 5
        $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
27 5
        $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
28
29
        // dc:creator
30 5
        $objWriter->writeElement('dc:creator', $this->oPresentation->getDocumentProperties()->getCreator());
31
32
        // cp:lastModifiedBy
33 5
        $objWriter->writeElement('cp:lastModifiedBy', $this->oPresentation->getDocumentProperties()->getLastModifiedBy());
34
35
        // dcterms:created
36 5
        $objWriter->startElement('dcterms:created');
37 5
        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
38 5
        $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getCreated()));
39 5
        $objWriter->endElement();
40
41
        // dcterms:modified
42 5
        $objWriter->startElement('dcterms:modified');
43 5
        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
44 5
        $objWriter->writeRaw(gmdate("Y-m-d\TH:i:s\Z", $this->oPresentation->getDocumentProperties()->getModified()));
45 5
        $objWriter->endElement();
46
47
        // dc:title
48 5
        $objWriter->writeElement('dc:title', $this->oPresentation->getDocumentProperties()->getTitle());
49
50
        // dc:description
51 5
        $objWriter->writeElement('dc:description', $this->oPresentation->getDocumentProperties()->getDescription());
52
53
        // dc:subject
54 5
        $objWriter->writeElement('dc:subject', $this->oPresentation->getDocumentProperties()->getSubject());
55
56
        // cp:keywords
57 5
        $objWriter->writeElement('cp:keywords', $this->oPresentation->getDocumentProperties()->getKeywords());
58
59
        // cp:category
60 5
        $objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
61
62 5
        if ($this->oPresentation->getPresentationProperties()->isMarkedAsFinal()) {
63
            // cp:contentStatus = Final
64
            $objWriter->writeElement('cp:contentStatus', 'Final');
65
        }
66
67 5
        $objWriter->endElement();
68
69 5
        $this->oZip->addFromString('docProps/core.xml', $objWriter->getData());
70
71
        // Return
72 5
        return $this->oZip;
73
    }
74
}
75