Code Duplication    Length = 26-26 lines in 4 locations

src/PhpSpreadsheet/Reader/Excel5.php 2 locations

@@ 4660-4685 (lines=26) @@
4657
4658
        // bit: 0-3; mask: 0x0000000F; type
4659
        $type = (0x0000000F & $options) >> 0;
4660
        switch ($type) {
4661
            case 0x00:
4662
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_NONE;
4663
                break;
4664
            case 0x01:
4665
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE;
4666
                break;
4667
            case 0x02:
4668
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_DECIMAL;
4669
                break;
4670
            case 0x03:
4671
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_LIST;
4672
                break;
4673
            case 0x04:
4674
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_DATE;
4675
                break;
4676
            case 0x05:
4677
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_TIME;
4678
                break;
4679
            case 0x06:
4680
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_TEXTLENGTH;
4681
                break;
4682
            case 0x07:
4683
                $type = \PhpSpreadsheet\Cell\DataValidation::TYPE_CUSTOM;
4684
                break;
4685
        }
4686
4687
        // bit: 4-6; mask: 0x00000070; error type
4688
        $errorStyle = (0x00000070 & $options) >> 4;
@@ 4719-4744 (lines=26) @@
4716
4717
        // bit: 20-23; mask: 0x00F00000; condition operator
4718
        $operator = (0x00F00000 & $options) >> 20;
4719
        switch ($operator) {
4720
            case 0x00:
4721
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_BETWEEN;
4722
                break;
4723
            case 0x01:
4724
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTBETWEEN;
4725
                break;
4726
            case 0x02:
4727
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_EQUAL;
4728
                break;
4729
            case 0x03:
4730
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_NOTEQUAL;
4731
                break;
4732
            case 0x04:
4733
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHAN;
4734
                break;
4735
            case 0x05:
4736
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHAN;
4737
                break;
4738
            case 0x06:
4739
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL;
4740
                break;
4741
            case 0x07:
4742
                $operator = \PhpSpreadsheet\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL;
4743
                break;
4744
        }
4745
4746
        // offset: 4; size: var; title of the prompt box
4747
        $offset = 4;

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

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