Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 918-929 (lines=12) @@
915
     * @return array|EE_Base_Class[]
916
     * @throws \EE_Error
917
     */
918
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
919
    {
920
        $model = $this->get_model();
921
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
922
            ? $model->get_primary_key_field()->get_name()
923
            : $field_to_order_by;
924
        $current_value = ! empty($field) ? $this->get($field) : null;
925
        if (empty($field) || empty($current_value)) {
926
            return array();
927
        }
928
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
929
    }
930
931
932
@@ 945-960 (lines=16) @@
942
     * @return array|EE_Base_Class[]
943
     * @throws \EE_Error
944
     */
945
    public function previous_x(
946
        $field_to_order_by = null,
947
        $limit = 1,
948
        $query_params = array(),
949
        $columns_to_select = null
950
    ) {
951
        $model = $this->get_model();
952
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
953
            ? $model->get_primary_key_field()->get_name()
954
            : $field_to_order_by;
955
        $current_value = ! empty($field) ? $this->get($field) : null;
956
        if (empty($field) || empty($current_value)) {
957
            return array();
958
        }
959
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
960
    }
961
962
963
@@ 975-986 (lines=12) @@
972
     * @return array|EE_Base_Class
973
     * @throws \EE_Error
974
     */
975
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
976
    {
977
        $model = $this->get_model();
978
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
979
            ? $model->get_primary_key_field()->get_name()
980
            : $field_to_order_by;
981
        $current_value = ! empty($field) ? $this->get($field) : null;
982
        if (empty($field) || empty($current_value)) {
983
            return array();
984
        }
985
        return $model->next($current_value, $field, $query_params, $columns_to_select);
986
    }
987
988
989
@@ 1001-1012 (lines=12) @@
998
     * @return array|EE_Base_Class
999
     * @throws \EE_Error
1000
     */
1001
    public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1002
    {
1003
        $model = $this->get_model();
1004
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1005
            ? $model->get_primary_key_field()->get_name()
1006
            : $field_to_order_by;
1007
        $current_value = ! empty($field) ? $this->get($field) : null;
1008
        if (empty($field) || empty($current_value)) {
1009
            return array();
1010
        }
1011
        return $model->previous($current_value, $field, $query_params, $columns_to_select);
1012
    }
1013
1014
1015