Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

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