Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DocPropsCore
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 render
100.00% covered (success)
100.00%
30 / 30
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4 * presentations documents.
5 *
6 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7 * General Public License version 3 as published by the Free Software Foundation.
8 *
9 * For the full copyright and license information, please read the LICENSE
10 * file that was distributed with this source code. For the full list of
11 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12 *
13 * @see        https://github.com/PHPOffice/PHPPresentation
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18declare(strict_types=1);
19
20namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
21
22use PhpOffice\Common\Adapter\Zip\ZipInterface;
23use PhpOffice\Common\XMLWriter;
24
25class DocPropsCore extends AbstractDecoratorWriter
26{
27    public function render(): ZipInterface
28    {
29        // Create XML writer
30        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
31
32        // XML header
33        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
34
35        // cp:coreProperties
36        $objWriter->startElement('cp:coreProperties');
37        $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
38        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
39        $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
40        $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
41        $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
42
43        // dc:creator
44        $objWriter->writeElement('dc:creator', $this->oPresentation->getDocumentProperties()->getCreator());
45
46        // cp:lastModifiedBy
47        $objWriter->writeElement('cp:lastModifiedBy', $this->oPresentation->getDocumentProperties()->getLastModifiedBy());
48
49        // dcterms:created
50        $objWriter->startElement('dcterms:created');
51        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
52        $objWriter->writeRaw(gmdate('Y-m-d\\TH:i:s\\Z', $this->oPresentation->getDocumentProperties()->getCreated()));
53        $objWriter->endElement();
54
55        // dcterms:modified
56        $objWriter->startElement('dcterms:modified');
57        $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
58        $objWriter->writeRaw(gmdate('Y-m-d\\TH:i:s\\Z', $this->oPresentation->getDocumentProperties()->getModified()));
59        $objWriter->endElement();
60
61        // dc:title
62        $objWriter->writeElement('dc:title', $this->oPresentation->getDocumentProperties()->getTitle());
63
64        // dc:description
65        $objWriter->writeElement('dc:description', $this->oPresentation->getDocumentProperties()->getDescription());
66
67        // dc:subject
68        $objWriter->writeElement('dc:subject', $this->oPresentation->getDocumentProperties()->getSubject());
69
70        // cp:keywords
71        $objWriter->writeElement('cp:keywords', $this->oPresentation->getDocumentProperties()->getKeywords());
72
73        // cp:category
74        $objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
75
76        // cp:revision
77        $objWriter->writeElement('cp:revision', $this->oPresentation->getDocumentProperties()->getRevision());
78
79        // cp:contentStatus
80        if ($this->oPresentation->getPresentationProperties()->isMarkedAsFinal()) {
81            $objWriter->writeElement('cp:contentStatus', 'Final');
82        } else {
83            $objWriter->writeElement('cp:contentStatus', $this->oPresentation->getDocumentProperties()->getStatus());
84        }
85
86        $objWriter->endElement();
87
88        $this->oZip->addFromString('docProps/core.xml', $objWriter->getData());
89
90        // Return
91        return $this->oZip;
92    }
93}