Failed Conditions
Push — master ( 27d83b...a2771e )
by Adrien
35:04
created

Settings::write()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 2.0002

Importance

Changes 0
Metric Value
cc 2
eloc 25
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 34
ccs 24
cts 25
cp 0.96
crap 2.0002
rs 8.8571
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
4
5
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
6
use PhpOffice\PhpSpreadsheet\Spreadsheet;
7
8
class Settings extends WriterPart
9
{
10
    /**
11
     * Write settings.xml to XML format.
12
     *
13
     * @param Spreadsheet $spreadsheet
14
     *
15
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
16
     *
17
     * @return string XML Output
18
     */
19 2
    public function write(Spreadsheet $spreadsheet = null)
0 ignored issues
show
Unused Code introduced by
The parameter $spreadsheet is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
    public function write(/** @scrutinizer ignore-unused */ Spreadsheet $spreadsheet = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21 2
        $objWriter = null;
22 2
        if ($this->getParentWriter()->getUseDiskCaching()) {
23
            $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
24
        } else {
25 2
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
26
        }
27
28
        // XML header
29 2
        $objWriter->startDocument('1.0', 'UTF-8');
30
31
        // Settings
32 2
        $objWriter->startElement('office:document-settings');
33 2
        $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
34 2
        $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
35 2
        $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0');
36 2
        $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
37 2
        $objWriter->writeAttribute('office:version', '1.2');
38
39 2
        $objWriter->startElement('office:settings');
40 2
        $objWriter->startElement('config:config-item-set');
41 2
        $objWriter->writeAttribute('config:name', 'ooo:view-settings');
42 2
        $objWriter->startElement('config:config-item-map-indexed');
43 2
        $objWriter->writeAttribute('config:name', 'Views');
44 2
        $objWriter->endElement();
45 2
        $objWriter->endElement();
46 2
        $objWriter->startElement('config:config-item-set');
47 2
        $objWriter->writeAttribute('config:name', 'ooo:configuration-settings');
48 2
        $objWriter->endElement();
49 2
        $objWriter->endElement();
50 2
        $objWriter->endElement();
51
52 2
        return $objWriter->getData();
53
    }
54
}
55