Code Duplication    Length = 19-22 lines in 3 locations

src/QueryBuilderServiceProvider.php 1 location

@@ 68-86 (lines=19) @@
65
66
            $filters = collect($filterParts);
67
68
            $filtersMapper = function ($value) {
69
                if (is_array($value)) {
70
                    return collect($value)->map($this->bindTo($this))->all();
71
                }
72
73
                if (Str::contains($value, ',')) {
74
                    return explode(',', $value);
75
                }
76
77
                if ($value === 'true') {
78
                    return true;
79
                }
80
81
                if ($value === 'false') {
82
                    return false;
83
                }
84
85
                return $value;
86
            };
87
88
            $filters = $filters->map($filtersMapper->bindTo($filtersMapper));
89

src/QueryBuilderRequest.php 2 locations

@@ 107-128 (lines=22) @@
104
        return collect($sortParts)->filter();
105
    }
106
107
    protected function getFilterValue($value)
108
    {
109
        if (is_array($value)) {
110
            return collect($value)->map(function ($valueValue) {
111
                return $this->getFilterValue($valueValue);
112
            })->all();
113
        }
114
115
        if (Str::contains($value, ',')) {
116
            return explode(',', $value);
117
        }
118
119
        if ($value === 'true') {
120
            return true;
121
        }
122
123
        if ($value === 'false') {
124
            return false;
125
        }
126
127
        return $value;
128
    }
129
130
    protected function getSearchValue($value)
131
    {
@@ 130-151 (lines=22) @@
127
        return $value;
128
    }
129
130
    protected function getSearchValue($value)
131
    {
132
        if (is_array($value)) {
133
            return collect($value)->map(function ($valueValue) {
134
                return $this->getSearchValue($valueValue);
135
            })->all();
136
        }
137
138
        if (Str::contains($value, ',')) {
139
            return explode(',', $value);
140
        }
141
142
        if ($value === 'true') {
143
            return true;
144
        }
145
146
        if ($value === 'false') {
147
            return false;
148
        }
149
150
        return $value;
151
    }
152
}
153