Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

@@ 2496-2510 (lines=15) @@
2493
                $extData = substr($recordData, $offset + 4, $cb);
2494
2495
                switch ($extType) {
2496
                    case 4:        // fill start color
2497
                        $xclfType = self::getUInt2d($extData, 0); // color type
2498
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2499
2500
                        if ($xclfType == 2) {
2501
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2502
2503
                            // modify the relevant style property
2504
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2505
                                $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
2506
                                $fill->getStartColor()->setRGB($rgb);
2507
                                unset($fill->startcolorIndex); // normal color index does not apply, discard
2508
                            }
2509
                        }
2510
2511
                        break;
2512
                    case 5:        // fill end color
2513
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2512-2526 (lines=15) @@
2509
                        }
2510
2511
                        break;
2512
                    case 5:        // fill end color
2513
                        $xclfType = self::getUInt2d($extData, 0); // color type
2514
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2515
2516
                        if ($xclfType == 2) {
2517
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2518
2519
                            // modify the relevant style property
2520
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2521
                                $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
2522
                                $fill->getEndColor()->setRGB($rgb);
2523
                                unset($fill->endcolorIndex); // normal color index does not apply, discard
2524
                            }
2525
                        }
2526
2527
                        break;
2528
                    case 7:        // border color top
2529
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2528-2542 (lines=15) @@
2525
                        }
2526
2527
                        break;
2528
                    case 7:        // border color top
2529
                        $xclfType = self::getUInt2d($extData, 0); // color type
2530
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2531
2532
                        if ($xclfType == 2) {
2533
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2534
2535
                            // modify the relevant style property
2536
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2537
                                $top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop();
2538
                                $top->getColor()->setRGB($rgb);
2539
                                unset($top->colorIndex); // normal color index does not apply, discard
2540
                            }
2541
                        }
2542
2543
                        break;
2544
                    case 8:        // border color bottom
2545
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2544-2558 (lines=15) @@
2541
                        }
2542
2543
                        break;
2544
                    case 8:        // border color bottom
2545
                        $xclfType = self::getUInt2d($extData, 0); // color type
2546
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2547
2548
                        if ($xclfType == 2) {
2549
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2550
2551
                            // modify the relevant style property
2552
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2553
                                $bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom();
2554
                                $bottom->getColor()->setRGB($rgb);
2555
                                unset($bottom->colorIndex); // normal color index does not apply, discard
2556
                            }
2557
                        }
2558
2559
                        break;
2560
                    case 9:        // border color left
2561
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2560-2574 (lines=15) @@
2557
                        }
2558
2559
                        break;
2560
                    case 9:        // border color left
2561
                        $xclfType = self::getUInt2d($extData, 0); // color type
2562
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2563
2564
                        if ($xclfType == 2) {
2565
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2566
2567
                            // modify the relevant style property
2568
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2569
                                $left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft();
2570
                                $left->getColor()->setRGB($rgb);
2571
                                unset($left->colorIndex); // normal color index does not apply, discard
2572
                            }
2573
                        }
2574
2575
                        break;
2576
                    case 10:        // border color right
2577
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2576-2590 (lines=15) @@
2573
                        }
2574
2575
                        break;
2576
                    case 10:        // border color right
2577
                        $xclfType = self::getUInt2d($extData, 0); // color type
2578
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2579
2580
                        if ($xclfType == 2) {
2581
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2582
2583
                            // modify the relevant style property
2584
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2585
                                $right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight();
2586
                                $right->getColor()->setRGB($rgb);
2587
                                unset($right->colorIndex); // normal color index does not apply, discard
2588
                            }
2589
                        }
2590
2591
                        break;
2592
                    case 11:        // border color diagonal
2593
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2592-2606 (lines=15) @@
2589
                        }
2590
2591
                        break;
2592
                    case 11:        // border color diagonal
2593
                        $xclfType = self::getUInt2d($extData, 0); // color type
2594
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2595
2596
                        if ($xclfType == 2) {
2597
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2598
2599
                            // modify the relevant style property
2600
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2601
                                $diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
2602
                                $diagonal->getColor()->setRGB($rgb);
2603
                                unset($diagonal->colorIndex); // normal color index does not apply, discard
2604
                            }
2605
                        }
2606
2607
                        break;
2608
                    case 13:    // font color
2609
                        $xclfType = self::getUInt2d($extData, 0); // color type
@@ 2608-2622 (lines=15) @@
2605
                        }
2606
2607
                        break;
2608
                    case 13:    // font color
2609
                        $xclfType = self::getUInt2d($extData, 0); // color type
2610
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2611
2612
                        if ($xclfType == 2) {
2613
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2614
2615
                            // modify the relevant style property
2616
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2617
                                $font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont();
2618
                                $font->getColor()->setRGB($rgb);
2619
                                unset($font->colorIndex); // normal color index does not apply, discard
2620
                            }
2621
                        }
2622
2623
                        break;
2624
                }
2625