Conditions | 6 |
Paths | 6 |
Total Lines | 35 |
Code Lines | 23 |
Lines | 22 |
Ratio | 62.86 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
53 | * @param ProgressControl $progress_control |
||
54 | */ |
||
55 | public function __construct(DataBaseFunctions $db_functions,HttpCalls $http_calls,ProgressControl $progress_control) |
||
56 | { |
||
57 | parent::__construct(); |
||
58 | |||
59 | $this->db_functions=$db_functions; |
||
60 | $this->http_calls=$http_calls; |
||
61 | $this->progress_control=$progress_control; |
||
62 | |||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Execute the console command. |
||
67 | * |
||
68 | * @return mixed |
||
69 | */ |
||
70 | public function handle() |
||
71 | { |
||
72 | $table='companies'; |
||
73 | |||
74 | DB::table($table)->truncate(); |
||
75 | |||
76 | $symbols_nasdq= '{"SymbolsNASDAQ":["AAL","AAPL","ADBE","ADI","ADP","ADSK","AKAM","ALXN","AMAT","AMGN","AMZN","ATVI","BBBY","BIDU","BIIB","BMRN","CA","CELG","CERN","CHKP","CHTR","CMCSA","COST","CSCO","CSX","CTRP","CTSH","CTXS","DISCA","DISCK","DISH","DLTR","EA","EBAY","ENDP","ESRX","EXPE","FAST","FB","FISV","FOX","FOXA","GILD","GOOG","GOOGL","HSIC","INCY","INTC","INTU","ILMN","ISRG","JD","KHC","LBTYA","LBTYK","LLTC","LMCA","LRCX","LVNTA","MAR","MAT","MDLZ","MNST","MSFT","MU","MXIM","MYL","NCLH","NFLX","NTAP","NVDA","NXPI","ORLY","PAYX","PCAR","PCLN","PYPL","QCOM","QVCA","REGN","ROST","SBAC","SBUX","SIRI","SNDK","SRCL","STX","SWKS","SYMC","TMUS","TSCO","TSLA","TRIP","TXN","ULTA","VIAB","VOD","VRSK","VRTX","WBA","WDC","WFM","XLNX","YHOO"]}'; |
||
77 | |||
78 | $symbols_nasdq = json_decode($symbols_nasdq); |
||
79 | |||
80 | $symbols = $symbols_nasdq->SymbolsNASDAQ; |
||
81 | |||
82 | for($i=0; $i<count($symbols); $i++){ |
||
|
|||
83 | try{ |
||
84 | $symbol=$symbols[$i]; |
||
85 | $data=$this->http_calls->getCompanies($symbol); |
||
86 | $this->db_functions->storeCompanies($data); |
||
87 | $this->progress_control->progressControl($i); |
||
88 | |||
95 | } |
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: