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