Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

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