Code Duplication    Length = 26-26 lines in 4 locations

src/PhpSpreadsheet/Reader/Xls.php 2 locations

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

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

@@ 2812-2837 (lines=26) @@
2809
2810
                // data type
2811
                $type = $dataValidation->getType();
2812
                switch ($type) {
2813
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE:
2814
                        $type = 0x00;
2815
                        break;
2816
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE:
2817
                        $type = 0x01;
2818
                        break;
2819
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL:
2820
                        $type = 0x02;
2821
                        break;
2822
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST:
2823
                        $type = 0x03;
2824
                        break;
2825
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE:
2826
                        $type = 0x04;
2827
                        break;
2828
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME:
2829
                        $type = 0x05;
2830
                        break;
2831
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH:
2832
                        $type = 0x06;
2833
                        break;
2834
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM:
2835
                        $type = 0x07;
2836
                        break;
2837
                }
2838
                $options |= $type << 0;
2839
2840
                // error style
@@ 2874-2899 (lines=26) @@
2871
2872
                // condition operator
2873
                $operator = $dataValidation->getOperator();
2874
                switch ($operator) {
2875
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN:
2876
                        $operator = 0x00;
2877
                        break;
2878
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN:
2879
                        $operator = 0x01;
2880
                        break;
2881
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL:
2882
                        $operator = 0x02;
2883
                        break;
2884
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL:
2885
                        $operator = 0x03;
2886
                        break;
2887
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN:
2888
                        $operator = 0x04;
2889
                        break;
2890
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN:
2891
                        $operator = 0x05;
2892
                        break;
2893
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL:
2894
                        $operator = 0x06;
2895
                        break;
2896
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL:
2897
                        $operator = 0x07;
2898
                        break;
2899
                }
2900
                $options |= $operator << 20;
2901
2902
                $data = pack('V', $options);