38 lines
980 B
PHP
38 lines
980 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum Sector: string
|
|
{
|
|
case PEMBANGKIT = 'Pembangkit Listrik';
|
|
case MANUFAKTUR = 'Industri Manufaktur';
|
|
case TRANSPORTASI = 'Transportasi';
|
|
case KOMERSIAL = 'Komersial';
|
|
case RUMAH_TANGGA = 'Rumah Tangga';
|
|
case ENERGI_LAINNYA = 'Lain-lain';
|
|
case PLN = 'Penggunaan Listrik PLN';
|
|
case AGRICULTURE = 'Pertanian';
|
|
case FOLU = 'Lahan';
|
|
case WASTE = 'Limbah';
|
|
|
|
public static function toArray(): array
|
|
{
|
|
return array_map(function ($case) {
|
|
return (object)[
|
|
'code' => strtolower(str_replace('_', '', $case->name)),
|
|
'name' => $case->value
|
|
];
|
|
}, self::cases());
|
|
}
|
|
|
|
public static function getName(string $code): ?string
|
|
{
|
|
foreach (self::cases() as $case) {
|
|
if (strtolower(str_replace(' ', '_', $case->name)) === $code) {
|
|
return $case->value;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|