Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

@@ 2351-2365 (lines=15) @@
2348
                $extData = substr($recordData, $offset + 4, $cb);
2349
2350
                switch ($extType) {
2351
                    case 4:        // fill start color
2352
                        $xclfType = self::getInt2d($extData, 0); // color type
2353
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
2354
2355
                        if ($xclfType == 2) {
2356
                            $rgb = sprintf('%02X%02X%02X', ord($xclrValue[0]), ord($xclrValue[1]), ord($xclrValue[2]));
2357
2358
                            // modify the relevant style property
2359
                            if (isset($this->mapCellXfIndex[$ixfe])) {
2360
                                $fill = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFill();
2361
                                $fill->getStartColor()->setRGB($rgb);
2362
                                unset($fill->startcolorIndex); // normal color index does not apply, discard
2363
                            }
2364
                        }
2365
                        break;
2366
                    case 5:        // fill end color
2367
                        $xclfType = self::getInt2d($extData, 0); // color type
2368
                        $xclrValue = substr($extData, 4, 4); // color value (value based on color type)
@@ 2366-2380 (lines=15) @@
2363
                            }
2364
                        }
2365
                        break;
2366
                    case 5:        // fill end 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->getEndColor()->setRGB($rgb);
2377
                                unset($fill->endcolorIndex); // normal color index does not apply, discard
2378
                            }
2379
                        }
2380
                        break;
2381
                    case 7:        // border color top
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 7:        // border color top
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
                                $top = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getTop();
2391
                                $top->getColor()->setRGB($rgb);
2392
                                unset($top->colorIndex); // normal color index does not apply, discard
2393
                            }
2394
                        }
2395
                        break;
2396
                    case 8:        // border color bottom
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 8:        // border color bottom
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
                                $bottom = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getBottom();
2406
                                $bottom->getColor()->setRGB($rgb);
2407
                                unset($bottom->colorIndex); // normal color index does not apply, discard
2408
                            }
2409
                        }
2410
                        break;
2411
                    case 9:        // border color left
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 9:        // border color left
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
                                $left = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getLeft();
2421
                                $left->getColor()->setRGB($rgb);
2422
                                unset($left->colorIndex); // normal color index does not apply, discard
2423
                            }
2424
                        }
2425
                        break;
2426
                    case 10:        // border color right
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 10:        // border color right
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
                                $right = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getRight();
2436
                                $right->getColor()->setRGB($rgb);
2437
                                unset($right->colorIndex); // normal color index does not apply, discard
2438
                            }
2439
                        }
2440
                        break;
2441
                    case 11:        // border color diagonal
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 11:        // border color diagonal
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
                                $diagonal = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
2451
                                $diagonal->getColor()->setRGB($rgb);
2452
                                unset($diagonal->colorIndex); // normal color index does not apply, discard
2453
                            }
2454
                        }
2455
                        break;
2456
                    case 13:    // font color
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 13:    // font color
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
                                $font = $this->spreadsheet->getCellXfByIndex($this->mapCellXfIndex[$ixfe])->getFont();
2466
                                $font->getColor()->setRGB($rgb);
2467
                                unset($font->colorIndex); // normal color index does not apply, discard
2468
                            }
2469
                        }
2470
                        break;
2471
                }
2472
2473
                $offset += $cb;