Code Duplication    Length = 26-26 lines in 4 locations

src/PhpSpreadsheet/Reader/Excel5.php 2 locations

@@ 4622-4647 (lines=26) @@
4619
4620
        // bit: 0-3; mask: 0x0000000F; type
4621
        $type = (0x0000000F & $options) >> 0;
4622
        switch ($type) {
4623
            case 0x00:
4624
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE;
4625
                break;
4626
            case 0x01:
4627
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE;
4628
                break;
4629
            case 0x02:
4630
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL;
4631
                break;
4632
            case 0x03:
4633
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST;
4634
                break;
4635
            case 0x04:
4636
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE;
4637
                break;
4638
            case 0x05:
4639
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME;
4640
                break;
4641
            case 0x06:
4642
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH;
4643
                break;
4644
            case 0x07:
4645
                $type = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM;
4646
                break;
4647
        }
4648
4649
        // bit: 4-6; mask: 0x00000070; error type
4650
        $errorStyle = (0x00000070 & $options) >> 4;
@@ 4681-4706 (lines=26) @@
4678
4679
        // bit: 20-23; mask: 0x00F00000; condition operator
4680
        $operator = (0x00F00000 & $options) >> 20;
4681
        switch ($operator) {
4682
            case 0x00:
4683
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN;
4684
                break;
4685
            case 0x01:
4686
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN;
4687
                break;
4688
            case 0x02:
4689
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL;
4690
                break;
4691
            case 0x03:
4692
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL;
4693
                break;
4694
            case 0x04:
4695
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN;
4696
                break;
4697
            case 0x05:
4698
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN;
4699
                break;
4700
            case 0x06:
4701
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL;
4702
                break;
4703
            case 0x07:
4704
                $operator = \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL;
4705
                break;
4706
        }
4707
4708
        // offset: 4; size: var; title of the prompt box
4709
        $offset = 4;

src/PhpSpreadsheet/Writer/Excel5/Worksheet.php 2 locations

@@ 2772-2797 (lines=26) @@
2769
2770
                // data type
2771
                $type = $dataValidation->getType();
2772
                switch ($type) {
2773
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE:
2774
                        $type = 0x00;
2775
                        break;
2776
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE:
2777
                        $type = 0x01;
2778
                        break;
2779
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL:
2780
                        $type = 0x02;
2781
                        break;
2782
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST:
2783
                        $type = 0x03;
2784
                        break;
2785
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE:
2786
                        $type = 0x04;
2787
                        break;
2788
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME:
2789
                        $type = 0x05;
2790
                        break;
2791
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH:
2792
                        $type = 0x06;
2793
                        break;
2794
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM:
2795
                        $type = 0x07;
2796
                        break;
2797
                }
2798
                $options |= $type << 0;
2799
2800
                // error style
@@ 2834-2859 (lines=26) @@
2831
2832
                // condition operator
2833
                $operator = $dataValidation->getOperator();
2834
                switch ($operator) {
2835
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN:
2836
                        $operator = 0x00;
2837
                        break;
2838
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN:
2839
                        $operator = 0x01;
2840
                        break;
2841
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL:
2842
                        $operator = 0x02;
2843
                        break;
2844
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL:
2845
                        $operator = 0x03;
2846
                        break;
2847
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN:
2848
                        $operator = 0x04;
2849
                        break;
2850
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN:
2851
                        $operator = 0x05;
2852
                        break;
2853
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL:
2854
                        $operator = 0x06;
2855
                        break;
2856
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL:
2857
                        $operator = 0x07;
2858
                        break;
2859
                }
2860
                $options |= $operator << 20;
2861
2862
                $data = pack('V', $options);