Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
Code Lines | 42 |
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 |
||
21 | public function events() |
||
22 | { |
||
23 | return [ |
||
24 | // Tenant events |
||
25 | Events\CreatingTenant::class => [], |
||
26 | Events\TenantCreated::class => [ |
||
27 | JobPipeline::make([ |
||
28 | Jobs\CreateDatabase::class, |
||
29 | Jobs\MigrateDatabase::class, |
||
30 | // Jobs\SeedDatabase::class, |
||
31 | |||
32 | // Your own jobs to prepare the tenant. |
||
33 | // Provision API keys, create S3 buckets, anything you want! |
||
34 | |||
35 | ])->send(fn (Events\TenantCreated $event) => $event->tenant)->shouldBeQueued(false), // `false` by default, but you probably want to make this `true` for production. |
||
36 | ], |
||
37 | Events\SavingTenant::class => [], |
||
38 | Events\TenantSaved::class => [], |
||
39 | Events\UpdatingTenant::class => [], |
||
40 | Events\TenantUpdated::class => [], |
||
41 | Events\DeletingTenant::class => [], |
||
42 | Events\TenantDeleted::class => [ |
||
43 | JobPipeline::make([ |
||
44 | Jobs\DeleteDatabase::class, |
||
45 | ])->send(fn (Events\TenantDeleted $event) => $event->tenant)->shouldBeQueued(false), // `false` by default, but you probably want to make this `true` for production. |
||
46 | ], |
||
47 | |||
48 | // Domain events |
||
49 | Events\CreatingDomain::class => [], |
||
50 | Events\DomainCreated::class => [], |
||
51 | Events\SavingDomain::class => [], |
||
52 | Events\DomainSaved::class => [], |
||
53 | Events\UpdatingDomain::class => [], |
||
54 | Events\DomainUpdated::class => [], |
||
55 | Events\DeletingDomain::class => [], |
||
56 | Events\DomainDeleted::class => [], |
||
57 | |||
58 | // Database events |
||
59 | Events\DatabaseCreated::class => [], |
||
60 | Events\DatabaseMigrated::class => [], |
||
61 | Events\DatabaseSeeded::class => [], |
||
62 | Events\DatabaseRolledBack::class => [], |
||
63 | Events\DatabaseDeleted::class => [], |
||
64 | |||
65 | // Tenancy events |
||
66 | Events\InitializingTenancy::class => [], |
||
67 | Events\TenancyInitialized::class => [ |
||
68 | Listeners\BootstrapTenancy::class, |
||
69 | ], |
||
70 | |||
71 | Events\EndingTenancy::class => [], |
||
72 | Events\TenancyEnded::class => [ |
||
73 | Listeners\RevertToCentralContext::class, |
||
74 | ], |
||
75 | |||
76 | Events\BootstrappingTenancy::class => [], |
||
77 | Events\TenancyBootstrapped::class => [], |
||
78 | Events\RevertingToCentralContext::class => [], |
||
79 | Events\RevertedToCentralContext::class => [], |
||
80 | |||
81 | // Resource syncing |
||
82 | Events\SyncedResourceSaved::class => [ |
||
83 | Listeners\UpdateSyncedResource::class, |
||
84 | ], |
||
85 | |||
86 | // Fired only when a synced resource is changed in a different DB than the origin DB (to avoid infinite loops) |
||
87 | Events\SyncedResourceChangedInForeignDatabase::class => [], |
||
88 | ]; |
||
142 |