Add VendorStrings to CPUs

This commit is contained in:
Timothy Warren 2024-05-28 18:44:29 -04:00
parent 7732999fa5
commit d6abde17ed
21 changed files with 876 additions and 850 deletions

View File

@ -211,7 +211,6 @@ return (new Config())
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
@ -233,7 +232,7 @@ return (new Config())
'yield',
],
],
'no_unneeded_curly_braces' => ['namespaces' => true],
'no_unneeded_braces' => ['namespaces' => true],
'no_unneeded_final_method' => ['private_methods' => true],
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
@ -478,6 +477,7 @@ return (new Config())
],
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
'space_inside_parenthesis' => false,
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,

804
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
],
'controller_resolver' => [
'auto_mapping' => true,
]
],
],
]);
};

View File

@ -3,6 +3,7 @@
namespace App\Controller;
use App\Entity\Cpu;
use App\Enum\CpuVendorString;
use App\Form\CpuType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -34,16 +35,44 @@ class CpuController extends AbstractController {
'model' => 'ASC',
]);
$amd = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'AMD' && $cpu->isReceived());
$intel = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'Intel' && $cpu->isReceived());
$others = array_filter($items, static fn (Cpu $cpu) => ( ! in_array($cpu->getBrand()->getName(), ['AMD', 'Intel'], TRUE)) && $cpu->isReceived());
$compare = static fn (Cpu $cpu1, Cpu $cpu2) => $cpu1->getId() <=> $cpu2->getId();
$filterByVendor = static function(array $items, CpuVendorString $vendorString): array
{
return array_filter($items, static fn (Cpu $cpu) => $cpu->getVendorString() === $vendorString);
};
$notReceived = array_filter($items, static fn (CPU $cpu) => $cpu->isReceived() === FALSE);
$items = array_udiff($items, $notReceived, $compare);
$noVendor = array_filter($items, static fn (Cpu $cpu) => $cpu->getVendorString() === null || $cpu->getVendorString() === '');
$items = array_udiff($items, $noVendor, $compare);
$amd = $filterByVendor($items, CpuVendorString::AMD);
$intel = $filterByVendor($items, CpuVendorString::INTEL);
$centaur = $filterByVendor($items, CpuVendorString::CENTAUR);
$cyrix = $filterByVendor($items, CpuVendorString::CYRIX);
$others = array_udiff($items, $amd, $intel, $centaur, $cyrix, $compare);
$sort = static function (Cpu $cpu1, Cpu $cpu2) {
$brandSort = $cpu1->getBrand()->getName() <=> $cpu2->getBrand()->getName();
$modelSort = $cpu1->getProductLine() <=> $cpu2->getProductLine();
return ($brandSort !== 0) ? $brandSort : $modelSort;
};
usort($notReceived, $sort);
usort($noVendor, $sort);
usort($amd, $sort);
usort($intel, $sort);
usort($centaur, $sort);
usort($cyrix, $sort);
usort($others, $sort);
return $this->render($template, [
'all' => [
'not_acquired' => $notReceived,
'amd' => $amd,
'intel' => $intel,
'centaur' => $centaur,
'cyrix' => $cyrix,
'no_vendor' => $noVendor,
'others' => $others,
],
]);

View File

@ -2,7 +2,7 @@
namespace App\Entity;
use App\Enum\CpuArchitecture;
use App\Enum\{CpuArchitecture, CpuVendorString};
use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\ORM\Mapping as ORM;
@ -15,6 +15,8 @@ trait CpuBase {
// ------------------------------------------------------------------------
// CPU Specs
// ------------------------------------------------------------------------
#[ORM\Column('vendor_string', type: 'string', length: 12, nullable: true, enumType: CpuVendorString::class)]
private ?CpuVendorString $vendorString = null;
#[ORM\Column('architecture', type: 'string', enumType: CpuArchitecture::class)]
private CpuArchitecture $architecture;

View File

@ -20,10 +20,10 @@ trait GetSet {
public function __set(string $name, mixed $value): void
{
if ( ! property_exists($this, $name))
{
throw new InvalidArgumentException("Undefined property: {$name}");
}
// if ( ! property_exists($this, $name))
// {
// throw new InvalidArgumentException("Undefined property: {$name}");
// }
$this->$name = $value;
}

View File

@ -3,26 +3,68 @@
namespace App\Enum;
enum CardBus: string {
// PCIe 1.0
case PCIE_10_1 = 'PCIe 1.0 x1';
case PCIE_10_4 = 'PCIe 1.0 x4';
case PCIE_10_8 = 'PCIe 1.0 x8';
case PCIE_10_16 = 'PCIe 1.0 x16';
// PCIe 1.1
case PCIE_11_1 = 'PCIe 1.1 x1';
case PCIE_11_4 = 'PCIe 1.1 x4';
case PCIE_11_8 = 'PCIe 1.1 x8';
case PCIE_11_16 = 'PCIe 1.1 x16';
// PCIe 2.0
case PCIE_20_1 = 'PCIe 2.0 x1';
case PCIE_20_4 = 'PCIe 2.0 x4';
case PCIE_20_8 = 'PCIe 2.0 x8';
case PCIE_20_16 = 'PCIe 2.0 x16';
// PCIe 3.0
case PCIE_30_1 = 'PCIe 3.0 x1';
case PCIE_30_4 = 'PCIe 3.0 x4';
case PCIE_30_8 = 'PCIe 3.0 x8';
case PCIE_30_16 = 'PCIe 3.0 x16';
// PCIe 4.0
case PCIE_40_1 = 'PCIe 4.0 x1';
case PCIE_40_4 = 'PCIe 4.0 x4';
case PCIE_40_8 = 'PCIe 4.0 x8';
case PCIE_40_16 = 'PCIe 4.0 x16';
// PCIe 5.0
case PCIE_50_1 = 'PCIe 5.0 x1';
case PCIE_50_4 = 'PCIe 5.0 x4';
case PCIE_50_8 = 'PCIe 5.0 x8';
case PCIE_50_16 = 'PCIe 5.0 x16';
// Future standards
/*
// PCIe 6.0
case PCIE_60_1 = 'PCIe 6.0 x1';
case PCIE_60_4 = 'PCIe 6.0 x4';
case PCIE_60_8 = 'PCIe 6.0 x8';
case PCIE_60_16 = 'PCIe 6.0 x16';
// PCIe 7.0
case PCIE_70_1 = 'PCIe 7.0 x1';
case PCIE_70_4 = 'PCIe 7.0 x4';
case PCIE_70_8 = 'PCIe 7.0 x8';
case PCIE_70_16 = 'PCIe 7.0 x16';
*/
// PCI
case PCI_33 = 'PCI 33';
case PCI_33V_33 = '3.3V PCI 33';
// AGP
case AGP_1X = 'AGP 1x';
case AGP_2X = 'AGP 2x';
case AGP_4X = 'AGP 4x';
case AGP_8X = 'AGP 8x';
// Etc.
case ISA_8 = '8-bit ISA';
case ISA_16 = '16-bit ISA';
case ISA_VLB = 'VLB';
@ -40,11 +82,15 @@ enum CardBus: string {
$isa = $filter('ISA_');
$pcie16 = array_filter($pcie, static fn (CardBus $case) => str_ends_with($case->name, '_16'));
$pcieOther = array_udiff($pcie, $pcie16, static fn ($a, $b) => $a->name <=> $b->name);
$pcie8 = array_filter($pcie, static fn (CardBus $case) => str_ends_with($case->name, '_8'));
$pcie4 = array_filter($pcie, static fn (CardBus $case) => str_ends_with($case->name, '_4'));
$pcie1 = array_filter($pcie, static fn (CardBus $case) => str_ends_with($case->name, '_1'));
return [
'PCI Express x16' => $pcie16,
'PCI Express Other' => $pcieOther,
'PCIe x16' => $pcie16,
'PCIe x8' => $pcie8,
'PCIe x4' => $pcie4,
'PCIe x1' => $pcie1,
'AGP' => $agp,
'PCI' => $pci,
'ISA' => $isa,

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace App\Enum;
enum CpuVendorString: string {
case AMD = 'AuthenticAMD';
case CENTAUR = 'CentaurHauls';
case CYRIX = 'CyrixInstead';
case INTEL = 'GenuineIntel';
case NATSEMI = "Geode\u{00A0}by\u{00A0}NSC";
case NEXGEN = 'NexGenDriven';
case RISE = 'RiseRiseRise';
case SIS = "SiS\u{00A0}SiS\u{00A0}SiS\u{00A0}";
case TRANSMETA = 'GenuineTMx86';
case UMC = "UMC\u{00A0}UMC\u{00A0}UMC\u{00A0}";
public static function getGroups(): array
{
return [
'Common' => [
null,
self::AMD,
self::INTEL,
],
'Others' => [
self::CENTAUR,
self::CYRIX,
self::NATSEMI,
self::NEXGEN,
self::RISE,
self::SIS,
self::TRANSMETA,
self::UMC,
],
];
}
}

View File

@ -3,10 +3,11 @@
namespace App\Enum;
enum SocketType: string {
case DUAL_INLINE_PACKAGE = 'DIP';
case LEAD_LESS_CHIP_CARRIER = 'LLCC';
case PLASTIC_LEADED_CHIP_CARRIER = 'PLCC';
case PIN_GRID_ARRAY = 'PGA';
case SLOT = 'Slot';
case LAND_GRID_ARRAY = 'LGA';
case BALL_GRID_ARRAY = 'BGA';
case LEAD_LESS_CHIP_CARRIER = 'LLCC';
case DUAL_INLINE_PACKAGE = 'DIP';
case PLASTIC_LEADED_CHIP_CARRIER = 'PLCC';
case SLOT = 'Slot';
}

View File

@ -2,6 +2,7 @@
namespace App\Form;
use App\Enum\CpuVendorString;
use App\Entity\
{Brand, Cpu, Socket};
use App\Enum\CpuArchitecture;
@ -26,6 +27,11 @@ class CpuType extends AbstractType {
'class' => Brand::class,
'query_builder' => self::filterBrands('cpu'),
])
->add('vendorString', EnumType::class, [
'class' => CpuVendorString::class,
'choice_label' => static fn (UnitEnum|NULL $choice): string => ($choice !== null) ? $choice->value : '(None)',
'choices' => CpuVendorString::getGroups(),
])
->add('sockets', EntityType::class, [
'class' => Socket::class,
'multiple' => true,

View File

@ -18,8 +18,6 @@ class SocketTypeForm extends AbstractType {
->add('brand', EntityType::class, [
'class' => Brand::class,
'query_builder' => self::getSocketBrands(),
'placeholder' => '[Generic]',
'required' => false,
])
->add('name')
->add('otherName')

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240509142844 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE collection.cpu ADD vendor_string VARCHAR(12) DEFAULT NULL');
$this->addSql('ALTER TABLE collection.previously_owned_cpu ADD vendor_string VARCHAR(12) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE collection.cpu DROP vendor_string');
$this->addSql('ALTER TABLE collection.previously_owned_cpu DROP vendor_string');
}
}

View File

@ -20,9 +20,10 @@
<div class="grid-x grid-margin-x">
<div class="cell">{{ form_row(form.architecture) }}</div>
<div class="cell">{{ form_row(form.sockets) }}</div>
<div class="cell medium-4">{{ form_row(form.brand) }}</div>
<div class="cell medium-4">{{ form_row(form.productLine) }}</div>
<div class="cell medium-4">{{ form_row(form.model) }}</div>
<div class="cell medium-6">{{ form_row(form.brand) }}</div>
<div class="cell medium-6">{{ form_row(form.vendorString) }}</div>
<div class="cell medium-6">{{ form_row(form.productLine) }}</div>
<div class="cell medium-6">{{ form_row(form.model) }}</div>
<div class="cell medium-6">{{ form_row(form.partNumber) }}</div>
<div class="cell medium-6">{{ form_row(form.lotNumber) }}</div>
<div class="cell medium-6">{{ form_row(form.microArchitecture) }}</div>

View File

@ -31,10 +31,18 @@
<li class="tabs-title">
<a href="#intel">Intel</a>
</li>
<li class="tabs-title">
<a href="#centaur">Centaur</a>
</li>
<li class="tabs-title">
<a href="#cyrix">Cyrix</a>
</li>
<li class="tabs-title">
<a href="#no_vendor">No Vendor String</a>
</li>
<li class="tabs-title">
<a href="#others">Others</a>
</li>
</ul>
<div class="tabs-content" data-tabs-content="classifications">
@ -44,23 +52,22 @@
<thead>
<tr>
<th>&nbsp;</th>
<th>Id</th>
<th>Arch</th>
<th>Model</th>
<!--<th>Id</th>
<th>Arch</th>-->
{% if label == 'not_acquired' or label == 'others' %}
<th>Vendor String</th>
{% endif %}
<th>Socket(s)</th>
<th>Part Number</th>
<th>Lot Number</th>
<th>uArch</th>
<th>Code Name</th>
<th>Speed</th>
<th>C/T</th>
<th>L1 Cache</th>
<th>L2 Cache</th>
<th>L3 Cache</th>
<th>Cache</th>
<th>Igp</th>
<th>Count</th>
<th>Usable</th>
<th>Received</th>
<th>Notes</th>
</tr>
</thead>
@ -81,9 +88,12 @@
</li>
</ul>
</td>
<td>{{ cpu.id }}</td>
<td>{{ cpu.architecture.value }}</td>
<td>{{ cpu.brand.name }} {{ cpu.productLine }} {{ cpu.model }}</td>
<td>{{ cpu.brand.name }} {{ cpu.productLine }} | {{ cpu.model }}</td>
<!-- <td>{{ cpu.id }}</td>
<td>{{ cpu.architecture.value }}</td>-->
{% if label == 'not_acquired' or label == 'others' %}
<td>{% if cpu.vendorString %}{{ cpu.vendorString.value }}{% endif %}</td>
{% endif %}
<td>
<ul>
{% for socket in cpu.sockets %}
@ -92,7 +102,6 @@
</ul>
</td>
<td>{{ cpu.partNumber }}</td>
<td>{{ cpu.lotNumber }}</td>
<td>{{ cpu.microArchitecture }}</td>
<td>{{ cpu.codeName }}</td>
<td>
@ -104,27 +113,22 @@
<td>{{ cpu.cores }} / {{ cpu.threads }}</td>
<td>
{% if cpu.L1uCount > 0 %}
{{ cpu.L1uCount }}x {{ cpu.L1uSize }}KB {{ cpu.L1uWay }}-way
{{ cpu.L1uCount }}x {{ cpu.L1uSize }}KB {{ cpu.L1uWay }}-way<br />
{% endif %}
{% if cpu.L1cCount > 0 %}
{{ cpu.L1cCount }}x {{ cpu.L1dSize }}KB {{ cpu.L1dWay }}-way data,
{{ cpu.L1dCount }}x {{ cpu.L1cSize }}KB {{ cpu.L1cWay }}-way instruction
L1d: {{ cpu.L1cCount }}x {{ cpu.L1dSize }}KB {{ cpu.L1dWay }}-way <br />
L1c: {{ cpu.L1dCount }}x {{ cpu.L1cSize }}KB {{ cpu.L1cWay }}-way <br />
{% endif %}
</td>
<td>
{% if cpu.L2Count > 0 %}
{{ cpu.L2Count }}x {{ cpu.L2Size }}KB {{ cpu.L2Way }}-way
<br />L2: {{ cpu.L2Count }}x {{ cpu.L2Size }}KB {{ cpu.L2Way }}-way
{% endif %}
</td>
<td>
{% if cpu.L3Count > 0 %}
{{ cpu.L3Count }}x {{ cpu.L3Size }}KB {{ cpu.L3Way }}-way
<br />L3: {{ cpu.L3Count }}x {{ cpu.L3Size }}KB {{ cpu.L3Way }}-way
{% endif %}
</td>
<td>{{ cpu.igp }}</td>
<td>{{ cpu.count }}</td>
<td>{{ cpu.usable ? 'Yes' : 'No' }}</td>
<td>{{ cpu.received ? 'Yes' : 'No' }}</td>
<td>{{ cpu.notes }}</td>
</tr>
{% else %}

View File

@ -37,6 +37,10 @@
<th>Architecture</th>
<td>{{ cpu.architecture.value }}</td>
</tr>
<tr>
<th>VendorStr</th>
<td>{% if cpu.vendorString %}{{ cpu.vendorString.value }}{% endif %}</td>
</tr>
<tr>
<th>Model</th>
<td>{{ cpu.brand.name }} {{ cpu.productLine }} {{ cpu.model }}</td>

View File

@ -20,9 +20,10 @@
<div class="grid-x grid-margin-x">
<div class="cell">{{ form_row(form.architecture) }}</div>
<div class="cell">{{ form_row(form.sockets) }}</div>
<div class="cell medium-4">{{ form_row(form.brand) }}</div>
<div class="cell medium-4">{{ form_row(form.productLine) }}</div>
<div class="cell medium-4">{{ form_row(form.model) }}</div>
<div class="cell medium-6">{{ form_row(form.brand) }}</div>
<div class="cell medium-6">{{ form_row(form.vendorString) }}</div>
<div class="cell medium-6">{{ form_row(form.productLine) }}</div>
<div class="cell medium-6">{{ form_row(form.model) }}</div>
<div class="cell medium-6">{{ form_row(form.partNumber) }}</div>
<div class="cell medium-6">{{ form_row(form.lotNumber) }}</div>
<div class="cell medium-6">{{ form_row(form.microArchitecture) }}</div>

View File

@ -12,6 +12,7 @@
<th>Id</th>
<th>Arch</th>
<th>Model</th>
<th>Vendor String</th>
<th>Socket(s)</th>
<th>Part Number</th>
<th>Lot Number</th>
@ -49,6 +50,7 @@
<td>{{ cpu.id }}</td>
<td>{{ cpu.architecture.value }}</td>
<td>{{ cpu.brand.name }} {{ cpu.productLine }} {{ cpu.model }}</td>
<td>{% if cpu.vendorString %}{{ cpu.vendorString.value }}{% endif %}</td>
<td>
<ul>
{% for socket in cpu.sockets %}

View File

@ -35,6 +35,10 @@
<tr>
<th>Architecture</th>
<td>{{ previously_owned_cpu.architecture }}</td>
</tr>
<tr>
<th>VendorStr</th>
<td>{% if previously_owned_cpu.vendorString %}{{ previously_owned_cpu.vendorString.value }}{% endif %}</td>
</tr>
<tr>
<th>ProductLine</th>

View File

@ -1,6 +1,6 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.6",
"rector/rector": "^0.17.6"
"friendsofphp/php-cs-fixer": "^3.52.1",
"rector/rector": "^1.0.3"
}
}

637
tools/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@ return [
'arm' => 'arm',
'arm64' => 'arm64',
'B & W' => 'B & W',
'BALL_GRID_ARRAY' => 'BGA',
'Base speed' => 'Base Speed',
'Batteries' => 'Batteries',
'Battery type' => 'Battery Type',
@ -149,13 +150,28 @@ return [
'PCIe 6-pin Power Connectors' => 'PCIe 6-pin Power Connectors',
'PCIe 8-pin Power Connectors' => 'PCIe 8-pin Power Connectors',
'PCIe 1.0 x16' => 'PCIe 1.0 x16',
'PCIe 1.0 x8' => 'PCIe 1.0 x8',
'PCIe 1.0 x4' => 'PCIe 1.0 x4',
'PCIe 1.0 x1' => 'PCIe 1.0 x1',
'PCIe 1.1 x16' => 'PCIe 1.1 x16',
'PCIe 1.1 x8' => 'PCIe 1.1 x8',
'PCIe 1.1 x4' => 'PCIe 1.1 x4',
'PCIe 1.1 x1' => 'PCIe 1.1 x1',
'PCIe 2.0 x16' => 'PCIe 2.0 x16',
'PCIe 2.0 x8' => 'PCIe 2.0 x8',
'PCIe 2.0 x4' => 'PCIe 2.0 x4',
'PCIe 2.0 x1' => 'PCIe 2.0 x1',
'PCIe 3.0 x1' => 'PCIe 3.0 x1',
'PCIe 3.0 x4' => 'PCIe 3.0 x4',
'PCIe 3.0 x8' => 'PCIe 3.0 x8',
'PCIe 3.0 x16' => 'PCIe 3.0 x16',
'PCIe 4.0 x1' => 'PCIe 4.0 x1',
'PCIe 4.0 x4' => 'PCIe 4.0 x4',
'PCIe 4.0 x8' => 'PCIe 4.0 x8',
'PCIe 4.0 x16' => 'PCIe 4.0 x16',
'PCIe 5.0 x1' => 'PCIe 5.0 x1',
'PCIe 5.0 x4' => 'PCIe 5.0 x4',
'PCIe 5.0 x8' => 'PCIe 5.0 x8',
'PCIe 5.0 x16' => 'PCIe 5.0 x16',
'PCIe x1' => 'PCIe x1',
'PCIe x4' => 'PCIe x4',