Completed
Push — master ( 0fe811...add005 )
by Ricardo
08:11
created

TransmissorCallbacks::handle()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 87

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 87
rs 8.2836
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Transmissor\Observers;
4
5
use Auth;
6
use Event;
7
use Illuminate\Support\Facades\Schema;
8
use Illuminate\Support\Str;
9
use Log;
10
use Pedreiro\Models\Base;
11
use Symfony\Component\Debug\Exception\FatalThrowableError;
12
use Throwable;
13
use Transmissor\Scopes\TransmissorScope;
14
use Transmissor\Services\TransmissorService;
15
16
/**
17
 * Call no-op classes on models for all event types.  This just simplifies
18
 * the handling of model events for models.
19
 */
20
class TransmissorCallbacks
21
{
22
    /**
23
     * Handle all model events, both Eloquent and Decoy
24
     *
25
     * @param  string $event
26
     * @param  array  $payload Contains:
27
     *                         -
28
     *                         Transmissor\Models\Base
29
     *                         $model
30
     * @return void
31
     */
32
    public function handle($event, $payload)
0 ignored issues
show
Unused Code introduced by
The parameter $event 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...
Unused Code introduced by
The parameter $payload 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...
33
    {
34
        // // list($model) = $payload;
35
        // dd($payload);
36
        // // // Payload
37
        // // ^ Cmgmyr\Messenger\Models\Message^ {#4332
38
        // //     #table: "messages"
39
        // //     #touches: array:1 [
40
        // //       0 => "thread"
41
        // //     ]
42
        // //     #fillable: array:3 [
43
        // //       0 => "thread_id"
44
        // //       1 => "user_id"
45
        // //       2 => "body"
46
        // //     ]
47
        // //     #dates: array:1 [
48
        // //       0 => "deleted_at"
49
        // //     ]
50
        // //     #connection: null
51
        // //     #primaryKey: "id"
52
        // //     #keyType: "int"
53
        // //     +incrementing: true
54
        // //     #with: []
55
        // //     #withCount: []
56
        // //     #perPage: 15
57
        // //     +exists: false
58
        // //     +wasRecentlyCreated: false
59
        // //     #attributes: []
60
        // //     #original: []
61
        // //     #changes: []
62
        // //     #casts: []
63
        // //     #dateFormat: null
64
        // //     #appends: []
65
        // //     #dispatchesEvents: []
66
        // //     #observables: []
67
        // //     #relations: []
68
        // //     +timestamps: true
69
        // //     #hidden: []
70
        // //     #visible: []
71
        // //     #guarded: array:1 [
72
        // //       0 => "*"
73
        // //     ]
74
        // //     #forceDeleting: false
75
        // //   }
76
77
        // // Ignore
78
        // if (!app()->bound(TransmissorService::class)) {
79
        //     return true;
80
        // }
81
82
        // if (!Schema::hasColumn($model->getTable(), 'business_code')) {
83
        //     return true;
84
        // }
85
          
86
87
        // // Get the action from the event name
88
        // preg_match('#\.(\w+)#', $event, $matches);
89
        // $action = $matches[1];
90
91
        // // If there is matching callback method on the model, call it, passing
92
        // // any additional event arguments to it
93
        // $method = 'on'.Str::studly($action);
94
95
        // if ($method == 'onBooting') {
96
        //     $model::addGlobalScope(new TransmissorScope);
97
        //     return true;
98
        // }
99
100
        // if ($method == 'onCreating') {
101
        //     $business = app()->make(TransmissorService::class);
102
        //     $model->business_code = $business->getCode();
103
        //     if (Auth::check()) {
104
        //         // @todo Verifica se tem acesso
105
        //     }
106
        //     return true;
107
        // }
108
        
109
        // if ($method == 'onCreated') {
110
        //     return true;
111
        // }
112
        
113
        // if ($method == 'onValidating' || $method == 'onValidated') {
114
        //     return true;
115
        // }
116
117
        // return true;
118
    }
119
}
120