Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 1015-1026 (lines=12) @@
1012
     * @throws InvalidDataTypeException
1013
     * @throws EE_Error
1014
     */
1015
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
1016
    {
1017
        $model         = $this->get_model();
1018
        $field         = empty($field_to_order_by) && $model->has_primary_key_field()
1019
            ? $model->get_primary_key_field()->get_name()
1020
            : $field_to_order_by;
1021
        $current_value = ! empty($field) ? $this->get($field) : null;
1022
        if (empty($field) || empty($current_value)) {
1023
            return array();
1024
        }
1025
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
1026
    }
1027
1028
1029
    /**
@@ 1045-1060 (lines=16) @@
1042
     * @throws InvalidDataTypeException
1043
     * @throws EE_Error
1044
     */
1045
    public function previous_x(
1046
        $field_to_order_by = null,
1047
        $limit = 1,
1048
        $query_params = array(),
1049
        $columns_to_select = null
1050
    ) {
1051
        $model         = $this->get_model();
1052
        $field         = empty($field_to_order_by) && $model->has_primary_key_field()
1053
            ? $model->get_primary_key_field()->get_name()
1054
            : $field_to_order_by;
1055
        $current_value = ! empty($field) ? $this->get($field) : null;
1056
        if (empty($field) || empty($current_value)) {
1057
            return array();
1058
        }
1059
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
1060
    }
1061
1062
1063
    /**
@@ 1078-1089 (lines=12) @@
1075
     * @throws InvalidDataTypeException
1076
     * @throws EE_Error
1077
     */
1078
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1079
    {
1080
        $model         = $this->get_model();
1081
        $field         = empty($field_to_order_by) && $model->has_primary_key_field()
1082
            ? $model->get_primary_key_field()->get_name()
1083
            : $field_to_order_by;
1084
        $current_value = ! empty($field) ? $this->get($field) : null;
1085
        if (empty($field) || empty($current_value)) {
1086
            return array();
1087
        }
1088
        return $model->next($current_value, $field, $query_params, $columns_to_select);
1089
    }
1090
1091
1092
    /**
@@ 1107-1118 (lines=12) @@
1104
     * @throws InvalidDataTypeException
1105
     * @throws EE_Error
1106
     */
1107
    public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1108
    {
1109
        $model         = $this->get_model();
1110
        $field         = empty($field_to_order_by) && $model->has_primary_key_field()
1111
            ? $model->get_primary_key_field()->get_name()
1112
            : $field_to_order_by;
1113
        $current_value = ! empty($field) ? $this->get($field) : null;
1114
        if (empty($field) || empty($current_value)) {
1115
            return array();
1116
        }
1117
        return $model->previous($current_value, $field, $query_params, $columns_to_select);
1118
    }
1119
1120
1121
    /**