mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Commands now use provider DI
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Helpers\SpeedtestHelper;
|
use App\Helpers\SpeedtestHelper;
|
||||||
|
use App\Interfaces\SpeedtestProvider;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
class SpeedtestCommand extends Command
|
class SpeedtestCommand extends Command
|
||||||
@@ -21,13 +22,17 @@ class SpeedtestCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'Performs a new speedtest';
|
protected $description = 'Performs a new speedtest';
|
||||||
|
|
||||||
|
private SpeedtestProvider $speedtestProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(SpeedtestProvider $speedtestProvider)
|
||||||
{
|
{
|
||||||
|
$this->speedtestProvider = $speedtestProvider;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Helpers\SpeedtestHelper;
|
use App\Helpers\SpeedtestHelper;
|
||||||
|
use App\Interfaces\SpeedtestProvider;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
@@ -22,13 +23,17 @@ class SpeedtestLatestCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'Returns the latest speedtest result';
|
protected $description = 'Returns the latest speedtest result';
|
||||||
|
|
||||||
|
private SpeedtestProvider $speedtestProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(SpeedtestProvider $speedtestProvider)
|
||||||
{
|
{
|
||||||
|
$this->speedtestProvider = $speedtestProvider;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,20 +18,11 @@ class SpeedtestServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
if (File::exists(env('DB_DATABASE'))) {
|
|
||||||
if (Schema::hasTable('settings')) {
|
|
||||||
switch (SettingsHelper::get('speedtest_provider')) {
|
|
||||||
case 'ookla':
|
|
||||||
default:
|
|
||||||
$this->app->singleton(
|
$this->app->singleton(
|
||||||
SpeedtestProvider::class,
|
SpeedtestProvider::class,
|
||||||
function () {
|
function () {
|
||||||
return new OoklaTester();
|
return new OoklaTester();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user