Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

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