Completed
Push — master ( 7d1812...246a65 )
by Scott
02:19
created

Carts   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
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 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 12 2
A store() 0 12 2
1
<?php namespace Bedard\Shop\Api;
2
3
use Bedard\Shop\Classes\ApiController;
4
use Bedard\Shop\Models\ApiSettings;
5
use Bedard\Shop\Repositories\CartRepository;
6
use Exception;
7
use Log;
8
9
class Carts extends ApiController
10
{
11
    /**
12
     * Show the current cart.
13
     *
14
     * @param  \Bedard\Shop\Repositories\CartRepository     $repository
15
     * @return \Bedard\Shop\Models\Cart
16
     */
17
    public function show(CartRepository $repository)
18
    {
19
        try {
0 ignored issues
show
Unused Code introduced by
This try statement is empty and can be removed.

This check looks for try blocks that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

If there is nothing in the try then the catch block can never be executed either. Thus, these try statements can be removed completely.

Loading history...
20
21
            // @todo
22
23
        } catch (Exception $e) {
0 ignored issues
show
Unused Code introduced by
catch (\Exception $e) { ...0, $e->getMessage()); } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
24
            Log::error($e->getMessage());
25
26
            abort(500, $e->getMessage());
27
        }
28
    }
29
30
    /**
31
     * Create a new cart.
32
     *
33
     * @param  \Bedard\Shop\Repositories\CartRepository     $repository
34
     * @return \Bedard\Shop\Models\Cart
35
     */
36
    public function store(CartRepository $repository)
37
    {
38
        try {
0 ignored issues
show
Unused Code introduced by
This try statement is empty and can be removed.

This check looks for try blocks that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

If there is nothing in the try then the catch block can never be executed either. Thus, these try statements can be removed completely.

Loading history...
39
40
            // @todo
41
42
        } catch (Exception $e) {
0 ignored issues
show
Unused Code introduced by
catch (\Exception $e) { ...0, $e->getMessage()); } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
43
            Log::error($e->getMessage());
44
45
            abort(500, $e->getMessage());
46
        }
47
    }
48
}
49