Completed
Push — master ( e62052...b5fe66 )
by Arthur
05:02
created

InductionController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php namespace BB\Http\Controllers;
2
3
use BB\Entities\Induction;
4
use BB\Exceptions\PaymentException;
5
use BB\Repo\PaymentRepository;
6
7
class InductionController extends Controller
8
{
9
10
    /**
11
     * @var \BB\Repo\InductionRepository
12
     */
13
    private $inductionRepository;
14
    /**
15
     * @var \BB\Repo\EquipmentRepository
16
     */
17
    private $equipmentRepository;
18
    /**
19
     * @var PaymentRepository
20
     */
21
    private $paymentRepository;
22
23
    /**
24
     * @param \BB\Repo\InductionRepository $inductionRepository
25
     */
26
    function __construct(\BB\Repo\InductionRepository $inductionRepository, \BB\Repo\EquipmentRepository $equipmentRepository, PaymentRepository $paymentRepository)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
27
    {
28
        $this->inductionRepository = $inductionRepository;
29
        $this->equipmentRepository = $equipmentRepository;
30
        $this->paymentRepository = $paymentRepository;
31
    }
32
33
34
    /**
35
     * Update the specified resource in storage.
36
     *
37
     * @param      $userId
38
     * @param  int $id
39
     * @throws \BB\Exceptions\NotImplementedException
40
     * @return \Illuminate\Http\RedirectResponse
41
     */
42
    public function update($userId, $id)
43
    {
44
        $induction = Induction::findOrFail($id);
45
46
        if (\Input::get('mark_trained', false)) {
47
            $induction->trained = \Carbon\Carbon::now();
48
            $induction->trainer_user_id = \Input::get('trainer_user_id', false);
49
            $induction->save();
50
        } elseif (\Input::get('is_trainer', false)) {
51
            $induction->is_trainer = true;
52
            $induction->save();
53
        } elseif (\Input::get('cancel_payment', false)) {
54
            if ($induction->trained) {
55
                throw new \BB\Exceptions\NotImplementedException();
56
            }
57
            //$payment = $this->paymentRepository->getById($induction->payment_id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
            $this->paymentRepository->refundPaymentToBalance($induction->payment_id);
59
            $this->inductionRepository->delete($id);
60
        } else {
61
            throw new \BB\Exceptions\NotImplementedException();
62
        }
63
        \Notification::success("Updated");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Updated does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
64
        return \Redirect::route('account.show', $userId);
0 ignored issues
show
Bug introduced by
The method route() does not seem to exist on object<redirect>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
65
    }
66
67
68
    /**
69
     * Remove the specified resource from storage.
70
     *
71
     * @param  int $id
72
     * @return Response
73
     */
74
    public function destroy($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        //
77
    }
78
79
80
}
81