Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 961-972 (lines=12) @@
958
     * @return array|EE_Base_Class[]
959
     * @throws \EE_Error
960
     */
961
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
962
    {
963
        $model = $this->get_model();
964
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
965
            ? $model->get_primary_key_field()->get_name()
966
            : $field_to_order_by;
967
        $current_value = ! empty($field) ? $this->get($field) : null;
968
        if (empty($field) || empty($current_value)) {
969
            return array();
970
        }
971
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
972
    }
973
974
975
@@ 988-1003 (lines=16) @@
985
     * @return array|EE_Base_Class[]
986
     * @throws \EE_Error
987
     */
988
    public function previous_x(
989
        $field_to_order_by = null,
990
        $limit = 1,
991
        $query_params = array(),
992
        $columns_to_select = null
993
    ) {
994
        $model = $this->get_model();
995
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
996
            ? $model->get_primary_key_field()->get_name()
997
            : $field_to_order_by;
998
        $current_value = ! empty($field) ? $this->get($field) : null;
999
        if (empty($field) || empty($current_value)) {
1000
            return array();
1001
        }
1002
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
1003
    }
1004
1005
1006
@@ 1018-1029 (lines=12) @@
1015
     * @return array|EE_Base_Class
1016
     * @throws \EE_Error
1017
     */
1018
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1019
    {
1020
        $model = $this->get_model();
1021
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1022
            ? $model->get_primary_key_field()->get_name()
1023
            : $field_to_order_by;
1024
        $current_value = ! empty($field) ? $this->get($field) : null;
1025
        if (empty($field) || empty($current_value)) {
1026
            return array();
1027
        }
1028
        return $model->next($current_value, $field, $query_params, $columns_to_select);
1029
    }
1030
1031
1032
@@ 1044-1055 (lines=12) @@
1041
     * @return array|EE_Base_Class
1042
     * @throws \EE_Error
1043
     */
1044
    public function previous($field_to_order_by = null, $query_params = array(), $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($current_value, $field, $query_params, $columns_to_select);
1055
    }
1056
1057
1058