| Total Complexity | 2 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ConvertPoolProperties extends Command |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The name and signature of the console command. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $signature = 'pools:convert'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The console command description. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $description = 'Convert pool properties'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Execute the console command. |
||
| 26 | * |
||
| 27 | * @return int |
||
| 28 | */ |
||
| 29 | public function handle() |
||
| 30 | { |
||
| 31 | $pools = Pool::get(); |
||
| 32 | foreach($pools as $pool) |
||
| 33 | { |
||
| 34 | $currProperties = $pool->properties; |
||
| 35 | $nextProperties = ['deposit' => [], 'remit' => []]; |
||
| 36 | $nextProperties['deposit']['fixed'] = $currProperties['deposit']['fixed'] ?? true; |
||
| 37 | $nextProperties['deposit']['lendable'] = $currProperties['remit']['lendable'] ?? false; |
||
| 38 | $nextProperties['remit']['planned'] = $currProperties['remit']['planned'] ?? true; |
||
| 39 | $nextProperties['remit']['auction'] = $currProperties['remit']['auction'] ?? false; |
||
| 40 | |||
| 41 | $currProperties['deposit'] = $nextProperties['deposit']; |
||
| 42 | $currProperties['remit'] = $nextProperties['remit']; |
||
| 43 | $pool->properties = $currProperties; |
||
| 44 | $pool->save(); |
||
| 45 | } |
||
| 46 | |||
| 47 | return Command::SUCCESS; |
||
| 48 | } |
||
| 50 |