asrock-memory-qvl-scraper/bin/app.php

35 lines
1.1 KiB
PHP

<?php
use Domain\Model\ASRockMemoryQVL;
use Domain\Model\MemoryConfiguration;
use Domain\Normalizer\Decorator\TweakersPricewatchUrl;
use Domain\Normalizer\MemoryConfigurationNormalizer;
use Encoder\EncoderFactory;
use IO\Downloader;
require_once __DIR__ . '/../vendor/autoload.php';
// setup
$qualifiedVendorList = new ASRockMemoryQVL('AMD', 'X570 Pro4', cpuFamily: 'MS');
$downloader = new Downloader();
$scraper = new MemoryQVLScraper();
// scrape and filter
$page = $downloader->download($qualifiedVendorList);
$configurations = $scraper->scrape($page);
$selection = $configurations->filter(static function (MemoryConfiguration $memory) {
return in_array($memory->numberOfModules, [2, 4])
&& $memory->totalSize >= 16
&& $memory->speed >= 3600
&& $memory->overclockingVerified;
});
// data presentation
$normalizer = new MemoryConfigurationNormalizer();
$normalizer = TweakersPricewatchUrl::decorate($normalizer);
$encoderFactory = new EncoderFactory($normalizer);
$encoding = $argv[1] ?? 'csv';
$encoder = $encoderFactory->getEncoder($encoding);
print($encoder->encode($selection));