Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

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