asrock-memory-qvl-scraper/bin/app.php
2021-04-22 19:26:09 +02:00

32 lines
1.0 KiB
PHP

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