store/app/Enums/RawMaterialUnit.php

56 lines
1.1 KiB
PHP

<?php
namespace App\Enums;
use App\Traits\ProvidesEnumOptions;
enum RawMaterialUnit: string
{
use ProvidesEnumOptions;
case YARD = 'yard';
case METER = 'meter';
case KILOGRAM = 'kilogram';
private const MIN_STOCK_YARD = 5.0;
private const MIN_STOCK_METER = 5.0;
private const MIN_STOCK_KILOGRAM = 2.0;
public function label(): string
{
return match ($this) {
self::YARD => 'Yard',
self::METER => 'Meter',
self::KILOGRAM => 'Kilogram',
};
}
public function abbreviation(): string
{
return match ($this) {
self::YARD => 'yard',
self::METER => 'm',
self::KILOGRAM => 'kg',
};
}
/**
* @return list<string>
*/
public static function values(): array
{
return array_column(self::cases(), 'value');
}
public function minStock(): float
{
return match ($this) {
self::YARD => self::MIN_STOCK_YARD,
self::METER => self::MIN_STOCK_METER,
self::KILOGRAM => self::MIN_STOCK_KILOGRAM,
};
}
}