Completed
Push — master ( df809c...204795 )
by Scott
04:21
created

Options   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 16 4
1
<?php namespace Bedard\Shop\Controllers;
2
3
use BackendMenu;
4
use Backend\Classes\Controller;
5
use Bedard\Shop\Models\Option;
6
use Exception;
7
use Response;
8
9
/**
10
 * Options Back-end Controller
11
 */
12
class Options extends Controller
13
{
14
    /**
15
     * Validate an option
16
     *
17
     * @return Response
18
     */
19
    public function validate()
20
    {
21
        $data = input('option');
22
        if (!$data || !is_array($data)) {
23
            return Response::make('Error', 422);
24
        }
25
26
        try {
27
            $option = new Option($data);
28
            $option->validate();
29
        } catch (Exception $e) {
30
            return Response::make($e->getMessage(), 400);
31
        }
32
33
        return Response::make($option, 200);
34
    }
35
}
36