Failed Conditions
Push — master ( 59326f...691b68 )
by Adrien
25:51 queued 17:10
created

MergedCells   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 26.47 %

Importance

Changes 0
Metric Value
dl 9
loc 34
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMergedCells() 0 17 2
A providerFormats() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Functional;
4
5
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6
7
class MergedCells extends AbstractFunctional
8
{
9 View Code Duplication
    public function providerFormats()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        return [
12
            ['Html'],
13
            ['Xls'],
14
            ['Xlsx'],
15
            ['Ods'],
16
        ];
17
    }
18
19
    /**
20
     * @dataProvider providerFormats
21
     *
22
     * @param string $format
23
     */
24
    public function testMergedCells($format)
25
    {
26
        $spreadsheet = new Spreadsheet();
27
        $spreadsheet->setActiveSheetIndex(0);
28
        $spreadsheet->getActiveSheet()->setCellValue('A1', '1');
29
        $spreadsheet->getActiveSheet()->setCellValue('B1', '2');
30
        $spreadsheet->getActiveSheet()->setCellValue('A2', '33');
31
        $spreadsheet->getActiveSheet()->mergeCells('A2:B2');
32
33
        $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
34
35
        $actual = 0;
36
        foreach ($reloadedSpreadsheet->getWorksheetIterator() as $worksheet) {
37
            $actual += count($worksheet->getMergeCells());
38
        }
39
40
        self::assertSame(1, $actual, "Format $format failed, could not read 1 merged cell");
41
    }
42
}
43