Completed
Push — develop ( 3560f1...5fce89 )
by Adrien
21:58 queued 15:06
created

Comment::write()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.4578

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 2
dl 0
loc 17
ccs 4
cts 14
cp 0.2857
crap 3.4578
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Ods\Cell;
4
5
/**
6
 * PhpSpreadsheet.
7
 *
8
 * Copyright (c) 2006 - 2015 PhpSpreadsheet
9
 *
10
 * This library is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU Lesser General Public
12
 * License as published by the Free Software Foundation; either
13
 * version 2.1 of the License, or (at your option) any later version.
14
 *
15
 * This library is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
 * Lesser General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Lesser General Public
21
 * License along with this library; if not, write to the Free Software
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
 *
24
 * @category   PhpSpreadsheet
25
 *
26
 * @copyright  Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
27
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
28
 */
29
30
/**
31
 * @category   PhpSpreadsheet
32
 *
33
 * @copyright  Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
34
 * @author     Alexander Pervakov <[email protected]>
35
 */
36
class Comment
37
{
38 2
    public static function write(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Cell $cell)
39
    {
40 2
        $comments = $cell->getWorksheet()->getComments();
41 2
        if (!isset($comments[$cell->getCoordinate()])) {
42 2
            return;
43
        }
44
        $comment = $comments[$cell->getCoordinate()];
45
46
        $objWriter->startElement('office:annotation');
47
        $objWriter->writeAttribute('svg:width', $comment->getWidth());
48
        $objWriter->writeAttribute('svg:height', $comment->getHeight());
49
        $objWriter->writeAttribute('svg:x', $comment->getMarginLeft());
50
        $objWriter->writeAttribute('svg:y', $comment->getMarginTop());
51
        $objWriter->writeElement('dc:creator', $comment->getAuthor());
52
        $objWriter->writeElement('text:p', $comment->getText()->getPlainText());
53
        $objWriter->endElement();
54
    }
55
}
56