Completed
Pull Request — develop (#186)
by
unknown
07:55
created

PptViewProps::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 31
CRAP Score 1

Importance

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

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 PptViewProps extends AbstractDecoratorWriter
7
{
8 75
    public function render()
9
    {
10
        // Create XML writer
11 75
        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
12
13
        // XML header
14 75
        $objWriter->startDocument('1.0', 'UTF-8', 'yes');
15
16
        // p:viewPr
17 75
        $objWriter->startElement('p:viewPr');
18 75
        $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
19 75
        $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
20 75
        $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main');
21 75
        $objWriter->writeAttribute('showComments', '0');
22
23
        // p:viewPr > p:slideViewPr
24 75
        $objWriter->startElement('p:slideViewPr');
25
26
        // p:viewPr > p:slideViewPr > p:cSldViewPr
27 75
        $objWriter->startElement('p:cSldViewPr');
28
29
        // p:viewPr > p:slideViewPr > p:cSldViewPr > p:cViewPr
30 75
        $objWriter->startElement('p:cViewPr');
31
32
        // p:viewPr > p:slideViewPr > p:cSldViewPr > p:cViewPr > p:scale
33 75
        $objWriter->startElement('p:scale');
34
35 75
        $objWriter->startElement('a:sx');
36 75
        $objWriter->writeAttribute('d', '100');
37 75
        $objWriter->writeAttribute('n', (int)($this->getPresentation()->getPresentationProperties()->getZoom() * 100));
38 75
        $objWriter->endElement();
39
40 75
        $objWriter->startElement('a:sy');
41 75
        $objWriter->writeAttribute('d', '100');
42 75
        $objWriter->writeAttribute('n', (int)($this->getPresentation()->getPresentationProperties()->getZoom() * 100));
43 75
        $objWriter->endElement();
44
45
        // > // p:viewPr > p:slideViewPr > p:cSldViewPr > p:cViewPr > p:scale
46 75
        $objWriter->endElement();
47
48 75
        $objWriter->startElement('p:origin');
49 75
        $objWriter->writeAttribute('x', '0');
50 75
        $objWriter->writeAttribute('y', '0');
51 75
        $objWriter->endElement();
52
53
        // > // p:viewPr > p:slideViewPr > p:cSldViewPr > p:cViewPr
54 75
        $objWriter->endElement();
55
56
        // > // p:viewPr > p:slideViewPr > p:cSldViewPr
57 75
        $objWriter->endElement();
58
59
        // > // p:viewPr > p:slideViewPr
60 75
        $objWriter->endElement();
61
62
        // > // p:viewPr
63 75
        $objWriter->endElement();
64
65 75
        $this->getZip()->addFromString('ppt/viewProps.xml', $objWriter->getData());
66
67 75
        return $this->getZip();
68
    }
69
}
70