Completed
Pull Request — develop (#390)
by Franck
06:30
created

PptPresProps::render()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 60

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 2.0036

Importance

Changes 0
Metric Value
dl 0
loc 60
ccs 28
cts 31
cp 0.9032
rs 8.8727
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0036

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
3
4
use PhpOffice\Common\XMLWriter;
5
6
class PptPresProps extends AbstractDecoratorWriter
7
{
8
    /**
9
     * @return \PhpOffice\Common\Adapter\Zip\ZipInterface
10
     * @throws \Exception
11
     */
12 112
    public function render()
13
    {
14 112
        $presentationPpts = $this->oPresentation->getPresentationProperties();
15
16
        // Create XML writer
17 112
        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
18
19
        // XML header
20 112
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
21
22
        // p:presentationPr
23 112
        $objWriter->startElement('p:presentationPr');
24 112
        $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
25 112
        $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
26 112
        $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
27
28
        // p:presentationPr > p:showPr
29 112
        if ($presentationPpts->isLoopContinuouslyUntilEsc()) {
30
            $objWriter->startElement('p:showPr');
31
            $objWriter->writeAttribute('loop', '1');
32
            $objWriter->endElement();
33
        }
34
35
        // p:extLst
36 112
        $objWriter->startElement('p:extLst');
37
38
        // p:ext
39 112
        $objWriter->startElement('p:ext');
40 112
        $objWriter->writeAttribute('uri', '{E76CE94A-603C-4142-B9EB-6D1370010A27}');
41
42
        // p14:discardImageEditData
43 112
        $objWriter->startElement('p14:discardImageEditData');
44 112
        $objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
45 112
        $objWriter->writeAttribute('val', '0');
46 112
        $objWriter->endElement();
47
48
        // > p:ext
49 112
        $objWriter->endElement();
50
51
        // p:ext
52 112
        $objWriter->startElement('p:ext');
53 112
        $objWriter->writeAttribute('uri', '{D31A062A-798A-4329-ABDD-BBA856620510}');
54
55
        // p14:defaultImageDpi
56 112
        $objWriter->startElement('p14:defaultImageDpi');
57 112
        $objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
58 112
        $objWriter->writeAttribute('val', '220');
59 112
        $objWriter->endElement();
60
61
        // > p:ext
62 112
        $objWriter->endElement();
63
        // > p:extLst
64 112
        $objWriter->endElement();
65
        // > p:presentationPr
66 112
        $objWriter->endElement();
67
68 112
        $this->getZip()->addFromString('ppt/presProps.xml', $objWriter->getData());
69
70 112
        return $this->getZip();
71
    }
72
}
73