Code Duplication    Length = 34-38 lines in 2 locations

app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php 2 locations

@@ 851-888 (lines=38) @@
848
     *
849
     * @return string
850
     */
851
    protected function _vcl_sub_maintenance_allowed_ips() {
852
        if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) {
853
            return false;
854
        }
855
856
        switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
857
            case 4.0:
858
                $tpl = <<<EOS
859
if (req.http.X-Forwarded-For) {
860
    if (req.http.X-Forwarded-For !~ "{{debug_ips}}") {
861
        return (synth(999, "Maintenance mode"));
862
    }
863
}
864
else {
865
    if (client.ip !~ debug_acl) {
866
        return (synth(999, "Maintenance mode"));
867
    }
868
}
869
870
EOS;
871
                break;
872
            default:
873
                $tpl = <<<EOS
874
if (req.http.X-Forwarded-For) {
875
    if(req.http.X-Forwarded-For !~ "{{debug_ips}}") {
876
        error 503;
877
    }
878
} else {
879
    if (client.ip !~ debug_acl) {
880
        error 503;
881
    }
882
}
883
EOS;
884
        }
885
886
        return $this->_formatTemplate($tpl, array(
887
            'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') ));
888
    }
889
890
    /**
891
     * Get the allowed IPs when in maintenance mode
@@ 895-928 (lines=34) @@
892
     *
893
     * @return string
894
     */
895
    protected function _vcl_sub_synth()
896
    {
897
        if (( ! $this->_getDebugIps()) || ! Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) {
898
            return false;
899
        }
900
901
        switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
902
            case 4.0:
903
                $tpl = <<<EOS
904
sub vcl_synth {
905
    if (resp.status == 999) {
906
        set resp.status = 404;
907
        set resp.http.Content-Type = "text/html; charset=utf-8";
908
        synthetic({"{{vcl_synth_content}}"});
909
        return (deliver);
910
    }
911
    return (deliver);
912
}
913
914
EOS;
915
                break;
916
            default:
917
                $tpl = <<<EOS
918
sub vcl_error {
919
    set obj.http.Content-Type = "text/html; charset=utf-8";
920
    synthetic {"{{vcl_synth_content}}"};
921
    return (deliver);
922
}
923
EOS;
924
        }
925
926
        return $this->_formatTemplate($tpl, array(
927
            'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')));
928
    }
929
930
931