Code Duplication    Length = 27-27 lines in 4 locations

src/PhpSpreadsheet/Shared/PCLZip/PclZip.php 4 locations

@@ 3412-3438 (lines=27) @@
3409
        }
3410
3411
        // ----- Look for pre-extract callback
3412
        if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3413
            // ----- Generate a local information
3414
            $v_local_header = [];
3415
            $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3416
3417
            // ----- Call the callback
3418
            // Here I do not use call_user_func() because I need to send a reference to the
3419
            // header.
3420
    //            eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3421
            $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3422
            if ($v_result == 0) {
3423
                // ----- Change the file status
3424
                $p_entry['status'] = 'skipped';
3425
                $v_result = 1;
3426
            }
3427
3428
            // ----- Look for abort result
3429
            if ($v_result == 2) {
3430
                // ----- This status is internal and will be changed in 'skipped'
3431
                $p_entry['status'] = 'aborted';
3432
                $v_result = PCLZIP_ERR_USER_ABORTED;
3433
            }
3434
3435
            // ----- Update the informations
3436
            // Only some fields can be modified
3437
            $p_entry['filename'] = $v_local_header['filename'];
3438
        }
3439
3440
        // ----- Look if extraction should be done
3441
        if ($p_entry['status'] == 'ok') {
@@ 3723-3749 (lines=27) @@
3720
        }
3721
3722
        // ----- Look for pre-extract callback
3723
        if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3724
            // ----- Generate a local information
3725
            $v_local_header = [];
3726
            $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3727
3728
            // ----- Call the callback
3729
            // Here I do not use call_user_func() because I need to send a reference to the
3730
            // header.
3731
    //            eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3732
            $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3733
            if ($v_result == 0) {
3734
                // ----- Change the file status
3735
                $p_entry['status'] = 'skipped';
3736
                $v_result = 1;
3737
            }
3738
3739
            // ----- Look for abort result
3740
            if ($v_result == 2) {
3741
                // ----- This status is internal and will be changed in 'skipped'
3742
                $p_entry['status'] = 'aborted';
3743
                $v_result = PCLZIP_ERR_USER_ABORTED;
3744
            }
3745
3746
            // ----- Update the informations
3747
            // Only some fields can be modified
3748
            $p_entry['filename'] = $v_local_header['filename'];
3749
        }
3750
3751
        // ----- Trace
3752
@@ 3829-3855 (lines=27) @@
3826
        }
3827
3828
        // ----- Look for pre-extract callback
3829
        if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3830
            // ----- Generate a local information
3831
            $v_local_header = [];
3832
            $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3833
3834
            // ----- Call the callback
3835
            // Here I do not use call_user_func() because I need to send a reference to the
3836
            // header.
3837
    //            eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3838
            $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3839
            if ($v_result == 0) {
3840
                // ----- Change the file status
3841
                $p_entry['status'] = 'skipped';
3842
                $v_result = 1;
3843
            }
3844
3845
            // ----- Look for abort result
3846
            if ($v_result == 2) {
3847
                // ----- This status is internal and will be changed in 'skipped'
3848
                $p_entry['status'] = 'aborted';
3849
                $v_result = PCLZIP_ERR_USER_ABORTED;
3850
            }
3851
3852
            // ----- Update the informations
3853
            // Only some fields can be modified
3854
            $p_entry['filename'] = $v_local_header['filename'];
3855
        }
3856
3857
        // ----- Look if extraction should be done
3858
        if ($p_entry['status'] == 'ok') {
@@ 3882-3908 (lines=27) @@
3879
        }
3880
3881
        // ----- Change abort status
3882
        if ($p_entry['status'] == 'aborted') {
3883
            $p_entry['status'] = 'skipped';
3884
        } elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3885
            // ----- Look for post-extract callback
3886
            // ----- Generate a local information
3887
            $v_local_header = [];
3888
            $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3889
3890
            // ----- Swap the content to header
3891
            $v_local_header['content'] = $p_string;
3892
            $p_string = '';
3893
3894
            // ----- Call the callback
3895
            // Here I do not use call_user_func() because I need to send a reference to the
3896
            // header.
3897
    //            eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3898
            $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3899
3900
            // ----- Swap back the content to header
3901
            $p_string = $v_local_header['content'];
3902
            unset($v_local_header['content']);
3903
3904
            // ----- Look for abort result
3905
            if ($v_result == 2) {
3906
                $v_result = PCLZIP_ERR_USER_ABORTED;
3907
            }
3908
        }
3909
3910
        // ----- Return
3911
        return $v_result;