Code Duplication    Length = 26-26 lines in 4 locations

src/PhpSpreadsheet/Writer/Xls/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);

src/PhpSpreadsheet/Reader/Xls.php 2 locations

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