Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

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