Completed
Pull Request — develop (#188)
by Franck
06:55
created

PptPresProps::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 60
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 60
ccs 31
cts 31
cp 1
rs 9.5555
cc 2
eloc 31
nc 2
nop 0
crap 2

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