Code Duplication    Length = 26-26 lines in 4 locations

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

@@ 2782-2807 (lines=26) @@
2779
2780
                // data type
2781
                $type = $dataValidation->getType();
2782
                switch ($type) {
2783
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_NONE:
2784
                        $type = 0x00;
2785
                        break;
2786
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE:
2787
                        $type = 0x01;
2788
                        break;
2789
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL:
2790
                        $type = 0x02;
2791
                        break;
2792
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST:
2793
                        $type = 0x03;
2794
                        break;
2795
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_DATE:
2796
                        $type = 0x04;
2797
                        break;
2798
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TIME:
2799
                        $type = 0x05;
2800
                        break;
2801
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH:
2802
                        $type = 0x06;
2803
                        break;
2804
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM:
2805
                        $type = 0x07;
2806
                        break;
2807
                }
2808
                $options |= $type << 0;
2809
2810
                // error style
@@ 2844-2869 (lines=26) @@
2841
2842
                // condition operator
2843
                $operator = $dataValidation->getOperator();
2844
                switch ($operator) {
2845
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN:
2846
                        $operator = 0x00;
2847
                        break;
2848
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN:
2849
                        $operator = 0x01;
2850
                        break;
2851
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL:
2852
                        $operator = 0x02;
2853
                        break;
2854
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL:
2855
                        $operator = 0x03;
2856
                        break;
2857
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN:
2858
                        $operator = 0x04;
2859
                        break;
2860
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN:
2861
                        $operator = 0x05;
2862
                        break;
2863
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL:
2864
                        $operator = 0x06;
2865
                        break;
2866
                    case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL:
2867
                        $operator = 0x07;
2868
                        break;
2869
                }
2870
                $options |= $operator << 20;
2871
2872
                $data = pack('V', $options);

src/PhpSpreadsheet/Reader/Xls.php 2 locations

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