Code Duplication    Length = 10-10 lines in 7 locations

src/think/response/View.php 1 location

@@ 115-124 (lines=10) @@
112
     * @param  mixed        $value 变量值
113
     * @return $this
114
     */
115
    public function assign($name, $value = null)
116
    {
117
        if (is_array($name)) {
118
            $this->vars = array_merge($this->vars, $name);
119
        } else {
120
            $this->vars[$name] = $value;
121
        }
122
123
        return $this;
124
    }
125
126
    /**
127
     * 视图内容过滤

src/think/Route.php 1 location

@@ 684-693 (lines=10) @@
681
     * @param array|bool   $resource 资源
682
     * @return $this
683
     */
684
    public function rest($name, $resource = [])
685
    {
686
        if (is_array($name)) {
687
            $this->rest = $resource ? $name : array_merge($this->rest, $name);
688
        } else {
689
            $this->rest[$name] = $resource;
690
        }
691
692
        return $this;
693
    }
694
695
    /**
696
     * 获取rest方法定义的参数

src/think/route/Resource.php 4 locations

@@ 186-195 (lines=10) @@
183
     * @param  array|string $validate 验证信息
184
     * @return $this
185
     */
186
    public function withValidate($name, $validate = [])
187
    {
188
        if (is_array($name)) {
189
            $this->validate = array_merge($this->validate, $name);
190
        } else {
191
            $this->validate[$name] = $validate;
192
        }
193
194
        return $this;
195
    }
196
197
    /**
198
     * 绑定资源模型
@@ 204-213 (lines=10) @@
201
     * @param  array|string $model 模型绑定
202
     * @return $this
203
     */
204
    public function withModel($name, $model = [])
205
    {
206
        if (is_array($name)) {
207
            $this->model = array_merge($this->model, $name);
208
        } else {
209
            $this->model[$name] = $model;
210
        }
211
212
        return $this;
213
    }
214
215
    /**
216
     * 绑定资源模型
@@ 222-231 (lines=10) @@
219
     * @param  array|string $middleware 中间件定义
220
     * @return $this
221
     */
222
    public function withMiddleware($name, $middleware = [])
223
    {
224
        if (is_array($name)) {
225
            $this->middleware = array_merge($this->middleware, $name);
226
        } else {
227
            $this->middleware[$name] = $middleware;
228
        }
229
230
        return $this;
231
    }
232
233
    /**
234
     * rest方法定义和修改
@@ 240-249 (lines=10) @@
237
     * @param  array|bool    $resource 资源
238
     * @return $this
239
     */
240
    public function rest($name, $resource = [])
241
    {
242
        if (is_array($name)) {
243
            $this->rest = $resource ? $name : array_merge($this->rest, $name);
244
        } else {
245
            $this->rest[$name] = $resource;
246
        }
247
248
        return $this;
249
    }
250
251
}
252

src/think/View.php 1 location

@@ 56-65 (lines=10) @@
53
     * @param mixed        $value 变量值
54
     * @return $this
55
     */
56
    public function assign($name, $value = null)
57
    {
58
        if (is_array($name)) {
59
            $this->data = array_merge($this->data, $name);
60
        } else {
61
            $this->data[$name] = $value;
62
        }
63
64
        return $this;
65
    }
66
67
    /**
68
     * 视图过滤