Completed
Pull Request — develop (#588)
by
unknown
08:47
created

PptPresProps::render()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 68

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 32
CRAP Score 2.0001

Importance

Changes 0
Metric Value
dl 0
loc 68
ccs 32
cts 33
cp 0.9697
rs 8.6981
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0001

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
        $objWriter->startElement('p:showPr');
30
31
        // loop attr
32 112
        if ($presentationPpts->isLoopContinuouslyUntilEsc()) {
33
            $objWriter->writeAttribute('loop', '1');
34
        }
35
36
        // show type
37 112
        $objWriter->startElement('p:'.$presentationPpts->getShowType());
38 112
        $objWriter->endElement();
39
        
40
        // > p:presentationPr > p:showPr
41 112
        $objWriter->endElement();
42
43
        // p:extLst
44 112
        $objWriter->startElement('p:extLst');
45
46
        // p:ext
47 112
        $objWriter->startElement('p:ext');
48 112
        $objWriter->writeAttribute('uri', '{E76CE94A-603C-4142-B9EB-6D1370010A27}');
49
50
        // p14:discardImageEditData
51 112
        $objWriter->startElement('p14:discardImageEditData');
52 112
        $objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
53 112
        $objWriter->writeAttribute('val', '0');
54 112
        $objWriter->endElement();
55
56
        // > p:ext
57 112
        $objWriter->endElement();
58
59
        // p:ext
60 112
        $objWriter->startElement('p:ext');
61 112
        $objWriter->writeAttribute('uri', '{D31A062A-798A-4329-ABDD-BBA856620510}');
62
63
        // p14:defaultImageDpi
64 112
        $objWriter->startElement('p14:defaultImageDpi');
65 112
        $objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
66 112
        $objWriter->writeAttribute('val', '220');
67 112
        $objWriter->endElement();
68
69
        // > p:ext
70 112
        $objWriter->endElement();
71
        // > p:extLst
72 112
        $objWriter->endElement();
73
        // > p:presentationPr
74 112
        $objWriter->endElement();
75
76 112
        $this->getZip()->addFromString('ppt/presProps.xml', $objWriter->getData());
77
78 112
        return $this->getZip();
79
    }
80
}
81