summaryrefslogtreecommitdiff
path: root/app/Console/Commands/ScrapeFile.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Console/Commands/ScrapeFile.php')
-rw-r--r--app/Console/Commands/ScrapeFile.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/Console/Commands/ScrapeFile.php b/app/Console/Commands/ScrapeFile.php
new file mode 100644
index 0000000..4cfef90
--- /dev/null
+++ b/app/Console/Commands/ScrapeFile.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Rugby\Factory\Service;
+use App\Rugby\Factory\SixnationsrugbyAdapter;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Storage;
+
+class ScrapeFile extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'scrape:file { filename }';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Scrape a file for data';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $filename = $this->argument('filename');
+
+ if (!Storage::disk('local')->exists($filename)) {
+ $this->error('Could not load file at: ' . Storage::disk('local')->path($filename));
+ return Command::FAILURE;
+ }
+
+ $raw_data = Storage::disk('local')->get($filename);
+
+ $service = new Service(new SixnationsrugbyAdapter($raw_data, 'Six Nations'));
+
+ $service->save();
+
+ return Command::SUCCESS;
+ }
+
+}