Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

@@ 2377-2391 (lines=15) @@
2374
                $extData = substr($recordData, $offset + 4, $cb);
2375
2376
                switch ($extType) {
2377
                    case 4:        // fill start color
2378
                        $xclfType  = self::getInt2d($extData, 0); // color type
2379
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2380
2381
                        if ($xclfType == 2) {
2382
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2383
2384
                            // modify the relevant style property
2385
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2386
                                $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
2387
                                $fill->getStartColor()->setRGB($rgb);
2388
                                unset($fill->startcolorIndex); // normal color index does not apply, discard
2389
                            }
2390
                        }
2391
                        break;
2392
                    case 5:        // fill end color
2393
                        $xclfType  = self::getInt2d($extData, 0); // color type
2394
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2392-2406 (lines=15) @@
2389
                            }
2390
                        }
2391
                        break;
2392
                    case 5:        // fill end color
2393
                        $xclfType  = self::getInt2d($extData, 0); // color type
2394
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2395
2396
                        if ($xclfType == 2) {
2397
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2398
2399
                            // modify the relevant style property
2400
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2401
                                $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
2402
                                $fill->getEndColor()->setRGB($rgb);
2403
                                unset($fill->endcolorIndex); // normal color index does not apply, discard
2404
                            }
2405
                        }
2406
                        break;
2407
                    case 7:        // border color top
2408
                        $xclfType  = self::getInt2d($extData, 0); // color type
2409
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2407-2421 (lines=15) @@
2404
                            }
2405
                        }
2406
                        break;
2407
                    case 7:        // border color top
2408
                        $xclfType  = self::getInt2d($extData, 0); // color type
2409
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2410
2411
                        if ($xclfType == 2) {
2412
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2413
2414
                            // modify the relevant style property
2415
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2416
                                $top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop();
2417
                                $top->getColor()->setRGB($rgb);
2418
                                unset($top->colorIndex); // normal color index does not apply, discard
2419
                            }
2420
                        }
2421
                        break;
2422
                    case 8:        // border color bottom
2423
                        $xclfType  = self::getInt2d($extData, 0); // color type
2424
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2422-2436 (lines=15) @@
2419
                            }
2420
                        }
2421
                        break;
2422
                    case 8:        // border color bottom
2423
                        $xclfType  = self::getInt2d($extData, 0); // color type
2424
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2425
2426
                        if ($xclfType == 2) {
2427
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2428
2429
                            // modify the relevant style property
2430
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2431
                                $bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom();
2432
                                $bottom->getColor()->setRGB($rgb);
2433
                                unset($bottom->colorIndex); // normal color index does not apply, discard
2434
                            }
2435
                        }
2436
                        break;
2437
                    case 9:        // border color left
2438
                        $xclfType  = self::getInt2d($extData, 0); // color type
2439
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2437-2451 (lines=15) @@
2434
                            }
2435
                        }
2436
                        break;
2437
                    case 9:        // border color left
2438
                        $xclfType  = self::getInt2d($extData, 0); // color type
2439
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2440
2441
                        if ($xclfType == 2) {
2442
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2443
2444
                            // modify the relevant style property
2445
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2446
                                $left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft();
2447
                                $left->getColor()->setRGB($rgb);
2448
                                unset($left->colorIndex); // normal color index does not apply, discard
2449
                            }
2450
                        }
2451
                        break;
2452
                    case 10:        // border color right
2453
                        $xclfType  = self::getInt2d($extData, 0); // color type
2454
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2452-2466 (lines=15) @@
2449
                            }
2450
                        }
2451
                        break;
2452
                    case 10:        // border color right
2453
                        $xclfType  = self::getInt2d($extData, 0); // color type
2454
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2455
2456
                        if ($xclfType == 2) {
2457
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2458
2459
                            // modify the relevant style property
2460
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2461
                                $right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight();
2462
                                $right->getColor()->setRGB($rgb);
2463
                                unset($right->colorIndex); // normal color index does not apply, discard
2464
                            }
2465
                        }
2466
                        break;
2467
                    case 11:        // border color diagonal
2468
                        $xclfType  = self::getInt2d($extData, 0); // color type
2469
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2467-2481 (lines=15) @@
2464
                            }
2465
                        }
2466
                        break;
2467
                    case 11:        // border color diagonal
2468
                        $xclfType  = self::getInt2d($extData, 0); // color type
2469
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2470
2471
                        if ($xclfType == 2) {
2472
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2473
2474
                            // modify the relevant style property
2475
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2476
                                $diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
2477
                                $diagonal->getColor()->setRGB($rgb);
2478
                                unset($diagonal->colorIndex); // normal color index does not apply, discard
2479
                            }
2480
                        }
2481
                        break;
2482
                    case 13:    // font color
2483
                        $xclfType  = self::getInt2d($extData, 0); // color type
2484
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2482-2496 (lines=15) @@
2479
                            }
2480
                        }
2481
                        break;
2482
                    case 13:    // font color
2483
                        $xclfType  = self::getInt2d($extData, 0); // color type
2484
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2485
2486
                        if ($xclfType == 2) {
2487
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
2488
2489
                            // modify the relevant style property
2490
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2491
                                $font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont();
2492
                                $font->getColor()->setRGB($rgb);
2493
                                unset($font->colorIndex); // normal color index does not apply, discard
2494
                            }
2495
                        }
2496
                        break;
2497
                }
2498
2499
                $offset += $cb;