Code Duplication    Length = 15-15 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

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