php-commerce/Data/SkuOption.php
Snider a774f4e285 refactor: migrate namespace from Core\Commerce to Core\Mod\Commerce
Align commerce module with the monorepo module structure by updating
all namespaces to use the Core\Mod\Commerce convention. This change
supports the recent monorepo separation and ensures consistency with
other modules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:23:12 +00:00

38 lines
684 B
PHP

<?php
declare(strict_types=1);
namespace Core\Mod\Commerce\Data;
/**
* A single option on a SKU.
*
* Example: ram~16gb*2 becomes SkuOption('ram', '16gb', 2)
*/
readonly class SkuOption
{
public function __construct(
public string $code,
public string $value,
public int $quantity = 1,
) {}
/**
* Build the string representation.
*/
public function toString(): string
{
$str = "{$this->code}~{$this->value}";
if ($this->quantity > 1) {
$str .= "*{$this->quantity}";
}
return $str;
}
public function __toString(): string
{
return $this->toString();
}
}