| 1 | <?php |
||
| 17 | class CompaniesTableFeeder extends Command |
||
| 18 | { |
||
| 19 | |||
| 20 | |||
| 21 | /** |
||
| 22 | * @var DataBaseFunctions |
||
| 23 | */ |
||
| 24 | protected $db_functions; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var HttpCalls |
||
| 28 | */ |
||
| 29 | protected $http_calls; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var ProgressControl |
||
| 33 | */ |
||
| 34 | protected $progress_control; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * The name and signature of the console command. |
||
| 38 | * |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $signature = 'companies_table:feed'; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The console command description. |
||
| 45 | * |
||
| 46 | * @var string |
||
| 47 | */ |
||
| 48 | protected $description = 'Feed the table companies from DB'; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Create a new command instance. |
||
| 52 | * @param DataBaseFunctions $db_functions |
||
| 53 | * @param HttpCalls $http_calls |
||
| 54 | * @param ProgressControl $progress_control |
||
| 55 | */ |
||
| 56 | public function __construct(DataBaseFunctions $db_functions,HttpCalls $http_calls,ProgressControl $progress_control) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Execute the console command. |
||
| 68 | * |
||
| 69 | * @return mixed |
||
| 70 | */ |
||
| 71 | public function handle() |
||
| 97 | } |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: