Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

@@ 940-951 (lines=12) @@
937
     * @return array|EE_Base_Class[]
938
     * @throws EE_Error
939
     */
940
    public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null)
941
    {
942
        $model = $this->get_model();
943
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
944
            ? $model->get_primary_key_field()->get_name()
945
            : $field_to_order_by;
946
        $current_value = ! empty($field) ? $this->get($field) : null;
947
        if (empty($field) || empty($current_value)) {
948
            return array();
949
        }
950
        return $model->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
951
    }
952
953
954
@@ 967-982 (lines=16) @@
964
     * @return array|EE_Base_Class[]
965
     * @throws EE_Error
966
     */
967
    public function previous_x(
968
        $field_to_order_by = null,
969
        $limit = 1,
970
        $query_params = array(),
971
        $columns_to_select = null
972
    ) {
973
        $model = $this->get_model();
974
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
975
            ? $model->get_primary_key_field()->get_name()
976
            : $field_to_order_by;
977
        $current_value = ! empty($field) ? $this->get($field) : null;
978
        if (empty($field) || empty($current_value)) {
979
            return array();
980
        }
981
        return $model->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
982
    }
983
984
985
@@ 997-1008 (lines=12) @@
994
     * @return array|EE_Base_Class
995
     * @throws EE_Error
996
     */
997
    public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
998
    {
999
        $model = $this->get_model();
1000
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1001
            ? $model->get_primary_key_field()->get_name()
1002
            : $field_to_order_by;
1003
        $current_value = ! empty($field) ? $this->get($field) : null;
1004
        if (empty($field) || empty($current_value)) {
1005
            return array();
1006
        }
1007
        return $model->next($current_value, $field, $query_params, $columns_to_select);
1008
    }
1009
1010
1011
@@ 1023-1034 (lines=12) @@
1020
     * @return array|EE_Base_Class
1021
     * @throws EE_Error
1022
     */
1023
    public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null)
1024
    {
1025
        $model = $this->get_model();
1026
        $field = empty($field_to_order_by) && $model->has_primary_key_field()
1027
            ? $model->get_primary_key_field()->get_name()
1028
            : $field_to_order_by;
1029
        $current_value = ! empty($field) ? $this->get($field) : null;
1030
        if (empty($field) || empty($current_value)) {
1031
            return array();
1032
        }
1033
        return $model->previous($current_value, $field, $query_params, $columns_to_select);
1034
    }
1035
1036
1037