Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 923-934 (lines=12) @@
920
     * @return array|EE_Base_Class[]
921
     * @throws \EE_Error
922
     */
923
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
924
    {
925
        $model = $this->get_model();
926
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
927
            ? $model->get_primary_key_field()->get_name()
928
            : $field_to_order_by;
929
        $current_value = ! empty($field) ? $this->get($field) : null;
930
        if (empty($field) || empty($current_value)) {
931
            return array();
932
        }
933
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
934
    }
935
936
937
@@ 950-965 (lines=16) @@
947
     * @return array|EE_Base_Class[]
948
     * @throws \EE_Error
949
     */
950
    public function previous_x(
951
        $field_to_order_by = null,
952
        $limit = 1,
953
        $query_params = array(),
954
        $columns_to_select = null
955
    ) {
956
        $model = $this->get_model();
957
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
958
            ? $model->get_primary_key_field()->get_name()
959
            : $field_to_order_by;
960
        $current_value = ! empty($field) ? $this->get($field) : null;
961
        if (empty($field) || empty($current_value)) {
962
            return array();
963
        }
964
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
965
    }
966
967
968
@@ 980-991 (lines=12) @@
977
     * @return array|EE_Base_Class
978
     * @throws \EE_Error
979
     */
980
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
981
    {
982
        $model = $this->get_model();
983
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
984
            ? $model->get_primary_key_field()->get_name()
985
            : $field_to_order_by;
986
        $current_value = ! empty($field) ? $this->get($field) : null;
987
        if (empty($field) || empty($current_value)) {
988
            return array();
989
        }
990
        return $model->next($current_value, $field, $query_params, $columns_to_select);
991
    }
992
993
994
@@ 1006-1017 (lines=12) @@
1003
     * @return array|EE_Base_Class
1004
     * @throws \EE_Error
1005
     */
1006
    public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1007
    {
1008
        $model = $this->get_model();
1009
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1010
            ? $model->get_primary_key_field()->get_name()
1011
            : $field_to_order_by;
1012
        $current_value = ! empty($field) ? $this->get($field) : null;
1013
        if (empty($field) || empty($current_value)) {
1014
            return array();
1015
        }
1016
        return $model->previous($current_value, $field, $query_params, $columns_to_select);
1017
    }
1018
1019
1020