| Total Lines | 84 |
| Code Lines | 67 |
| 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 |
||
| 91 | public function register() |
||
| 92 | { |
||
| 93 | $this->app->singleton(LocaleService::class, function($app) { |
||
| 94 | $vendorDir = base_path('vendor'); |
||
| 95 | // Read country list from the umpirsky/country-list package data. |
||
| 96 | $countriesDataDir = $vendorDir . '/umpirsky/country-list/data'; |
||
| 97 | // Read currency list from the umpirsky/currency-list package data. |
||
| 98 | $currenciesDataDir = $vendorDir . '/umpirsky/currency-list/data'; |
||
| 99 | $localization = $app->make(LaravelLocalization::class); |
||
| 100 | return new LocaleService($localization, $countriesDataDir, $currenciesDataDir); |
||
| 101 | }); |
||
| 102 | $this->app->singleton(SqidsInterface::class, function() { |
||
| 103 | return new Sqids(minLength: 8); |
||
| 104 | }); |
||
| 105 | |||
| 106 | $this->app->singleton(FundService::class, FundService::class); |
||
| 107 | $this->app->singleton(ChargeService::class, ChargeService::class); |
||
| 108 | $this->app->singleton(CategoryService::class, CategoryService::class); |
||
| 109 | $this->app->singleton(FixedFeeService::class, FixedFeeService::class); |
||
| 110 | $this->app->singleton(LibreFeeService::class, LibreFeeService::class); |
||
| 111 | $this->app->singleton(BillService::class, BillService::class); |
||
| 112 | $this->app->singleton(SettlementService::class, SettlementService::class); |
||
| 113 | $this->app->singleton(SettlementTargetService::class, SettlementTargetService::class); |
||
| 114 | |||
| 115 | $this->app->singleton(SavingService::class, SavingService::class); |
||
| 116 | $this->app->singleton(DebtCalculator::class, DebtCalculator::class); |
||
| 117 | $this->app->singleton(LoanService::class, LoanService::class); |
||
| 118 | $this->app->singleton(AuctionService::class, AuctionService::class); |
||
| 119 | $this->app->singleton(DepositService::class, DepositService::class); |
||
| 120 | $this->app->singleton(BalanceCalculator::class, BalanceCalculator::class); |
||
| 121 | $this->app->singleton(DisbursementService::class, DisbursementService::class); |
||
| 122 | $this->app->singleton(MeetingPoolService::class, MeetingPoolService::class); |
||
| 123 | $this->app->singleton(RefundService::class, RefundService::class); |
||
| 124 | $this->app->singleton(ProfitService::class, ProfitService::class); |
||
| 125 | $this->app->singleton(RemitmentService::class, RemitmentService::class); |
||
| 126 | $this->app->singleton(MeetingSummaryService::class, MeetingSummaryService::class); |
||
| 127 | $this->app->singleton(MeetingSessionService::class, MeetingSessionService::class); |
||
| 128 | $this->app->singleton(PresenceService::class, PresenceService::class); |
||
| 129 | $this->app->singleton(MemberReportService::class, MemberReportService::class); |
||
| 130 | $this->app->singleton(RoundReportService::class, RoundReportService::class); |
||
| 131 | $this->app->singleton(SessionReportService::class, SessionReportService::class); |
||
| 132 | $this->app->singleton(ReportService::class, ReportService::class); |
||
| 133 | $this->app->singleton(PrinterService::class, PrinterService::class); |
||
| 134 | $this->app->when(PrinterService::class) |
||
| 135 | ->needs('$config') |
||
| 136 | ->give(config('chrome.page')); |
||
| 137 | |||
| 138 | $this->app->singleton(RoundService::class, RoundService::class); |
||
| 139 | $this->app->singleton(PlanningSessionService::class, PlanningSessionService::class); |
||
| 140 | $this->app->singleton(SubscriptionService::class, SubscriptionService::class); |
||
| 141 | $this->app->singleton(PlanningSummaryService::class, PlanningSummaryService::class); |
||
| 142 | |||
| 143 | $this->app->singleton(TenantService::class, TenantService::class); |
||
| 144 | $this->app->singleton(TontinePoolService::class, TontinePoolService::class); |
||
| 145 | $this->app->singleton(GuestService::class, GuestService::class); |
||
| 146 | $this->app->singleton(MemberService::class, MemberService::class); |
||
| 147 | $this->app->singleton(TontineService::class, TontineService::class); |
||
| 148 | $this->app->singleton(PaymentServiceInterface::class, function() { |
||
| 149 | return new class implements PaymentServiceInterface { |
||
| 150 | // By default, all the payment items are editable. |
||
| 151 | public function isEditable(Model $item): bool |
||
| 152 | { |
||
| 153 | return true; |
||
| 154 | } |
||
| 155 | }; |
||
| 156 | }); |
||
| 157 | |||
| 158 | $this->app->singleton(ChargeValidator::class, ChargeValidator::class); |
||
| 159 | $this->app->singleton(DebtValidator::class, DebtValidator::class); |
||
| 160 | $this->app->singleton(SavingValidator::class, SavingValidator::class); |
||
| 161 | $this->app->singleton(ClosingValidator::class, ClosingValidator::class); |
||
| 162 | $this->app->singleton(DisbursementValidator::class, DisbursementValidator::class); |
||
| 163 | $this->app->singleton(LoanValidator::class, LoanValidator::class); |
||
| 164 | $this->app->singleton(MemberValidator::class, MemberValidator::class); |
||
| 165 | $this->app->singleton(RoundValidator::class, RoundValidator::class); |
||
| 166 | $this->app->singleton(PoolValidator::class, PoolValidator::class); |
||
| 167 | $this->app->singleton(PoolRoundValidator::class, PoolRoundValidator::class); |
||
| 168 | $this->app->singleton(RemitmentValidator::class, RemitmentValidator::class); |
||
| 169 | $this->app->singleton(SessionValidator::class, SessionValidator::class); |
||
| 170 | $this->app->singleton(OptionsValidator::class, OptionsValidator::class); |
||
| 171 | $this->app->singleton(TontineValidator::class, TontineValidator::class); |
||
| 172 | $this->app->singleton(TargetValidator::class, TargetValidator::class); |
||
| 173 | $this->app->singleton(GuestAccessValidator::class, GuestAccessValidator::class); |
||
| 174 | $this->app->singleton(GuestInviteValidator::class, GuestInviteValidator::class); |
||
| 175 | } |
||
| 177 |