Skip to content

Commit a440c41

Browse files
author
Adil Ausagit
committed
#32 best solution?
1 parent 41a57e4 commit a440c41

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/Commands/MakeEntityCommand.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -194,30 +194,23 @@ protected function checkConfigs()
194194

195195
protected function outputInfo($newProjectConfigs, $oldProjectConfigs)
196196
{
197-
$newProjectConfigsFullDepthValues = [];
198-
$newProjectConfigsFullDepthKeys = [];
199-
$oldProjectConfigsFullDepthValues = [];
200-
$oldProjectConfigsFullDepthKeys = [];
201-
202-
array_walk_recursive($newProjectConfigs, function ($value, $key) use (&$newProjectConfigsFullDepthValues, &$newProjectConfigsFullDepthKeys) {
203-
$newProjectConfigsFullDepthValues[] = $value;
204-
$newProjectConfigsFullDepthKeys[] = $key;
205-
});
197+
$newProjectConfigsFullDepth = [];
198+
$oldProjectConfigsFullDepth = [];
206199

207-
array_walk_recursive($oldProjectConfigs, function ($value, $key) use (&$oldProjectConfigsFullDepthValues, &$oldProjectConfigsFullDepthKeys) {
208-
$oldProjectConfigsFullDepthValues[] = $value;
209-
$oldProjectConfigsFullDepthKeys[] = $key;
200+
array_walk_recursive($newProjectConfigs, function ($value, $key) use (&$newProjectConfigsFullDepth) {
201+
$newProjectConfigsFullDepth[$value] = $key;
210202
});
211203

212-
$differentValues = array_diff($newProjectConfigsFullDepthValues, $oldProjectConfigsFullDepthValues);
213-
$differentKeys = array_diff($newProjectConfigsFullDepthKeys, $oldProjectConfigsFullDepthKeys);
204+
array_walk_recursive($oldProjectConfigs, function ($value, $key) use (&$oldProjectConfigsFullDepth) {
205+
$oldProjectConfigsFullDepth[$value] = $key;
206+
});
214207

215-
if (!empty($differentKeys)) {
216-
$this->info("Added new keys : " . implode(", ", $differentKeys));
217-
}
208+
$differences = array_diff_key($newProjectConfigsFullDepth, $oldProjectConfigsFullDepth);
218209

219-
if (!empty($differentValues)) {
220-
$this->info("Added new values : " . implode(", ", $differentValues));
210+
if (!empty($differences)) {
211+
foreach ($differences as $differenceKey => $differenceValue) {
212+
$this->info("Key `{$differenceValue}` was missing in your config, we added it with the value `{$differenceKey}`");
213+
}
221214
}
222215
}
223216

0 commit comments

Comments
 (0)