Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 1010-1021 (lines=12) @@
1007
     * @throws InvalidDataTypeException
1008
     * @throws EE_Error
1009
     */
1010
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
1011
    {
1012
        $model = $this->get_model();
1013
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1014
            ? $model->get_primary_key_field()->get_name()
1015
            : $field_to_order_by;
1016
        $current_value = ! empty($field) ? $this->get($field) : null;
1017
        if (empty($field) || empty($current_value)) {
1018
            return array();
1019
        }
1020
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
1021
    }
1022
1023
1024
    /**
@@ 1040-1055 (lines=16) @@
1037
     * @throws InvalidDataTypeException
1038
     * @throws EE_Error
1039
     */
1040
    public function previous_x(
1041
        $field_to_order_by = null,
1042
        $limit = 1,
1043
        $query_params = array(),
1044
        $columns_to_select = null
1045
    ) {
1046
        $model = $this->get_model();
1047
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1048
            ? $model->get_primary_key_field()->get_name()
1049
            : $field_to_order_by;
1050
        $current_value = ! empty($field) ? $this->get($field) : null;
1051
        if (empty($field) || empty($current_value)) {
1052
            return array();
1053
        }
1054
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
1055
    }
1056
1057
1058
    /**
@@ 1073-1084 (lines=12) @@
1070
     * @throws InvalidDataTypeException
1071
     * @throws EE_Error
1072
     */
1073
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1074
    {
1075
        $model = $this->get_model();
1076
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1077
            ? $model->get_primary_key_field()->get_name()
1078
            : $field_to_order_by;
1079
        $current_value = ! empty($field) ? $this->get($field) : null;
1080
        if (empty($field) || empty($current_value)) {
1081
            return array();
1082
        }
1083
        return $model->next($current_value, $field, $query_params, $columns_to_select);
1084
    }
1085
1086
1087
    /**
@@ 1102-1113 (lines=12) @@
1099
     * @throws InvalidDataTypeException
1100
     * @throws EE_Error
1101
     */
1102
    public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1103
    {
1104
        $model = $this->get_model();
1105
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1106
            ? $model->get_primary_key_field()->get_name()
1107
            : $field_to_order_by;
1108
        $current_value = ! empty($field) ? $this->get($field) : null;
1109
        if (empty($field) || empty($current_value)) {
1110
            return array();
1111
        }
1112
        return $model->previous($current_value, $field, $query_params, $columns_to_select);
1113
    }
1114
1115
1116
    /**