Conditions | 10 |
Paths | 512 |
Total Lines | 34 |
Code Lines | 23 |
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 |
||
102 | public function storeConfiguration(array $data): bool |
||
103 | { |
||
104 | /** @var AccountRepositoryInterface $repository */ |
||
105 | $repository = app(AccountRepositoryInterface::class); |
||
106 | $importId = $data['csv_import_account'] ?? 0; |
||
107 | $account = $repository->find(intval($importId)); |
||
108 | |||
109 | $hasHeaders = isset($data['has_headers']) && 1 === intval($data['has_headers']) ? true : false; |
||
110 | $config = $this->job->configuration; |
||
111 | $config['initial-config-complete'] = true; |
||
112 | $config['has-headers'] = $hasHeaders; |
||
113 | $config['date-format'] = $data['date_format']; |
||
114 | $config['delimiter'] = $data['csv_delimiter']; |
||
115 | $config['delimiter'] = 'tab' === $config['delimiter'] ? "\t" : $config['delimiter']; |
||
116 | $config['apply_rules'] = isset($data['apply_rules']) && 1 === intval($data['apply_rules']) ? true : false; |
||
117 | $config['match_bills'] = isset($data['match_bills']) && 1 === intval($data['match_bills']) ? true : false; |
||
118 | |||
119 | Log::debug('Entered import account.', ['id' => $importId]); |
||
120 | |||
121 | if (null !== $account->id) { |
||
122 | Log::debug('Found account.', ['id' => $account->id, 'name' => $account->name]); |
||
123 | $config['import-account'] = $account->id; |
||
124 | } |
||
125 | |||
126 | if (null === $account->id) { |
||
127 | Log::error('Could not find anything for csv_import_account.', ['id' => $importId]); |
||
128 | } |
||
129 | |||
130 | $config = $this->storeSpecifics($data, $config); |
||
131 | $this->job->configuration = $config; |
||
132 | $this->job->save(); |
||
133 | |||
134 | return true; |
||
135 | } |
||
136 | |||
160 |