Code Duplication    Length = 74-74 lines in 2 locations

app/Console/Commands/CompanyFollowTableFeeder.php 1 location

@@ 15-88 (lines=74) @@
12
 * Class CompanyFollowTableFeeder
13
 * @package App\Console\Commands
14
 */
15
class CompanyFollowTableFeeder extends Command
16
{
17
18
    /**
19
     * @var DataBaseFunctions
20
     */
21
    protected $db_functions;
22
23
    /**
24
     * @var HttpCalls
25
     */
26
    protected $http_calls;
27
28
    /**
29
     * @var ProgressControl
30
     */
31
    protected $progress_control;
32
33
    /**
34
     * The name and signature of the console command.
35
     *
36
     * @var string
37
     */
38
    protected $signature = 'company_follow:feed';
39
40
    /**
41
     * The console command description.
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Feed the table companies_follow from DB';
46
47
    /**
48
     * Create a new command instance.
49
     * @param DataBaseFunctions $db_functions
50
     * @param HttpCalls $http_calls
51
     * @param ProgressControl $progress_control
52
     */
53
    public function __construct(DataBaseFunctions $db_functions,HttpCalls $http_calls,ProgressControl $progress_control)
54
    {
55
        parent::__construct();
56
57
        $this->db_functions=$db_functions;
58
        $this->http_calls=$http_calls;
59
        $this->progress_control=$progress_control;
60
61
    }
62
63
    /**
64
     * Execute the console command.
65
     *
66
     * @return mixed
67
     */
68
    public function handle()
69
    {
70
        $table='company_follow';
71
72
        $symbols=$this->db_functions->truncateBDValuesAndGetNew($table);
73
74
        for($i=0; $i<count($symbols); $i++){
75
            try{
76
77
                $symbol=$symbols[$i]->symbol;
78
                $data=$this->http_calls->getTableFollow($symbol);
79
                $this->db_functions->storeCompanyFollowTable($data,$table);
80
                $this->progress_control->progressControl($i);
81
82
            }catch(Exception $e){
83
84
            }
85
        }
86
        echo("100% Table company_follow fed\n");
87
    }
88
}
89

app/Console/Commands/ExchangeHistoryTableFeeder.php 1 location

@@ 19-92 (lines=74) @@
16
 * Class ExchangeHistoryTableFeeder
17
 * @package App\Console\Commands
18
 */
19
class ExchangeHistoryTableFeeder extends Command
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 = 'history_table:feed';
42
43
    /**
44
     * The console command description.
45
     *
46
     * @var string
47
     */
48
    protected $description = 'Feed the table exchange_history 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)
57
    {
58
        parent::__construct();
59
60
        $this->db_functions=$db_functions;
61
        $this->http_calls=$http_calls;
62
        $this->progress_control=$progress_control;
63
64
    }
65
66
67
    /**
68
     * Execute the console command.
69
     *
70
     * @return mixed
71
     */
72
    public function handle()
73
    {
74
        $table='exchange_history';
75
76
        $symbols=$this->db_functions->truncateBDValuesAndGetNew($table);
77
78
        for($i=0; $i<count($symbols); $i++){
79
            try{
80
81
                $symbol=$symbols[$i]->symbol;
82
                $data=$this->http_calls->getExchangeHistory($symbol);
83
                $this->db_functions->storeExchangeHistory($data,$table);
84
                $this->progress_control->progressControl($i);
85
86
            }catch(Exception $e){
87
88
            }
89
        }
90
        echo("100% Table exchange_history fed\n");
91
    }
92
}
93