Code Duplication    Length = 18-18 lines in 2 locations

controllers/Options.php 2 locations

@@ 20-37 (lines=18) @@
17
     *
18
     * @return Response
19
     */
20
    public function create()
21
    {
22
        $data = input('option');
23
        if (! $data || ! is_array($data)) {
24
            return Response::make('Error', 422);
25
        }
26
27
        try {
28
            $sessionKey = uniqid('session_key', true);
29
            $option = Option::create($data);
30
            $product = new Product;
31
            $product->options()->add($option, $sessionKey);
32
33
            return Response::make($option, 202);
34
        } catch (Exception $e) {
35
            return Response::make($e->getMessage(), 500);
36
        }
37
    }
38
39
    /**
40
     * Create a value with deferred bindings to an option.
@@ 44-61 (lines=18) @@
41
     *
42
     * @return Response
43
     */
44
    public function createValue()
45
    {
46
        $data = input('value');
47
        if (! $data || ! is_array($data)) {
48
            return Response::make('Error', 422);
49
        }
50
51
        try {
52
            $sessionKey = uniqid('session_key', true);
53
            $value = OptionValue::create($data);
54
            $option = new Option;
55
            $option->values()->add($value, $sessionKey);
56
57
            return Response::make($value, 202);
58
        } catch (Exception $e) {
59
            return Response::make($e->getMessage(), 500);
60
        }
61
    }
62
63
    /**
64
     * Validate an option.