Code Duplication    Length = 11-13 lines in 3 locations

src/Http/Api/ModuleController.php 1 location

@@ 112-122 (lines=11) @@
109
        }
110
111
        $name = $request->input('name');
112
        if (isset($name))
113
        {
114
            if (!$name)
115
            {
116
                throw new \UnexpectedValueException('the name can not be empty.', -11400);
117
            }
118
            if ($module->name !== $name && Module::whereRaw([ 'name' => $name ])->exists())
119
            {
120
                throw new \UnexpectedValueException('module name cannot be repeated', -11401);
121
            }
122
        }
123
124
        $principal_id = $request->input('principal');
125
        if (isset($principal_id))

src/Http/Api/UserController.php 1 location

@@ 324-336 (lines=13) @@
321
        }
322
323
        $email = $request->input('email');
324
        if (isset($email))
325
        {
326
            if (!$email)
327
            {
328
                throw new \UnexpectedValueException('the email can not be empty.', -10101);
329
            }
330
            if ($user = Sentinel::findByCredentials([ 'email' => $email ]))
331
            {
332
                if ($user->id !== $id) {
333
                    throw new \InvalidArgumentException('email has already existed.', -10102);
334
                }
335
            }
336
        }
337
338
        $user = Sentinel::findById($id);
339
        if (!$user)

src/Http/Api/VersionController.php 1 location

@@ 228-239 (lines=12) @@
225
        }
226
227
        $name = $request->input('name');
228
        if (isset($name))
229
        {
230
            if (!$name)
231
            {
232
                throw new \UnexpectedValueException('the name can not be empty.', -11500);
233
            }
234
235
            if ($version->name !== $name && Version::whereRaw([ 'name' => $name, 'project_key' => $project_key ])->exists())
236
            {
237
                throw new \UnexpectedValueException('version name cannot be repeated', -11501);
238
            }
239
        }
240
241
        $start_time = $request->input('start_time') ? $request->input('start_time') : $version->start_time;
242
        $end_time = $request->input('end_time') ? $request->input('end_time') : $version->end_time;