Code Duplication    Length = 26-26 lines in 4 locations

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

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

src/PhpSpreadsheet/Reader/Xls.php 2 locations

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