Code Duplication    Length = 12-16 lines in 4 locations

core/db_classes/EE_Base_Class.class.php 4 locations

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