54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Domain\Model;
|
|
|
|
class MemoryConfiguration
|
|
{
|
|
public int $moduleSize;
|
|
public int $totalSize;
|
|
public string $totalSizeHr;
|
|
public int $numberOfModules;
|
|
public bool $overclockingVerified;
|
|
public bool $dualChannelOverclockingVerified;
|
|
|
|
public function __construct(
|
|
public string $type,
|
|
public string $vendor,
|
|
public int $speed,
|
|
public int $supportedSpeed,
|
|
public string $moduleSizeHr,
|
|
public string $module,
|
|
public string $chip,
|
|
public bool $isDualSided,
|
|
public string $dimmSocketSupport,
|
|
public string $overclockingSupport,
|
|
public string $note
|
|
)
|
|
{
|
|
$this->moduleSize = filter_var($this->moduleSizeHr, FILTER_SANITIZE_NUMBER_INT);
|
|
$this->overclockingVerified = in_array($this->overclockingSupport, ['v', '2'], true);
|
|
$this->dualChannelOverclockingVerified = $this->overclockingSupport === '2';
|
|
|
|
$this->deriveAdditionalFields();
|
|
}
|
|
|
|
private function deriveAdditionalFields(): void
|
|
{
|
|
$this->findTotalSize();
|
|
$this->numberOfModules = $this->totalSize / $this->moduleSize;
|
|
}
|
|
|
|
private function findTotalSize(): void
|
|
{
|
|
// Initially 8 times the module size
|
|
$this->totalSize = 8 * $this->moduleSize;
|
|
|
|
// Work our way down to the module size...
|
|
while (!str_contains($this->module, $this->totalSize) && $this->totalSize > $this->moduleSize) {
|
|
$this->totalSize /= 2;
|
|
}
|
|
|
|
$this->totalSizeHr = sprintf('%dGB', $this->totalSize);
|
|
}
|
|
}
|