Conditions | 1 |
Paths | 1 |
Total Lines | 87 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
32 | public function handle($event, $payload) |
||
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 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.