/ app / Enums / SectorialDimensionsEnum.php
SectorialDimensionsEnum.php
 1  <?php
 2  
 3  namespace App\Enums;
 4  
 5  use Log;
 6  
 7  enum SectorialDimensionsEnum: string
 8  {
 9      case DEFENSE = 'Defense';
10      case ENERGY = 'Energy';
11      case FINANCIAL = 'Financial';
12      case INDUSTRIAL = 'Industrial';
13      case PUBLICADMINISTRATION = 'Public Administration';
14      case HEALTH = 'Health';
15      case SPACE = 'Space';
16      case TELECOMM = 'Telecomm';
17      case TRANSPORTATION = 'Transportation';
18      case CONSUMER = 'Consumer';
19      case GENERALIT = 'General IT';
20      case RESEARCHANDEDUCATION = 'Research and Education';
21      case OTHERGENERALINDUSTRIES = 'Other General Industries';
22      case SECTORINDEPENDENT = 'Sector Independent';
23      case NONE = 'None';
24  
25      public static function toArray()
26      {
27          return array_column(SectorialDimensionsEnum::cases(), 'value');
28      }
29  
30      public static function getNumber()
31      {
32          return count(SectorialDimensionsEnum::toArray());
33      }
34  
35      public static function valueNameArray(): array
36      {
37          return collect(self::cases())->map(function ($sectorialDimension) {
38              return [
39                  'id' => $sectorialDimension->value,
40                  'name' => self::getTranslation($sectorialDimension->name),
41              ];
42          })->toArray();
43      }
44  
45      public static function getTranslation(string $key)
46      {
47          return match ($key) {
48              'DEFENSE' => __('toes.sectorial_dimensions.defense'),
49              'ENERGY' => __('toes.sectorial_dimensions.energy'),
50              'FINANCIAL' => __('toes.sectorial_dimensions.financial'),
51              'INDUSTRIAL' => __('toes.sectorial_dimensions.industrial'),
52              'PUBLICADMINISTRATION' => __('toes.sectorial_dimensions.public_administration'),
53              'HEALTH' => __('toes.sectorial_dimensions.health'),
54              'SPACE' => __('toes.sectorial_dimensions.space'),
55              'TELECOMM' => __('toes.sectorial_dimensions.telecomm'),
56              'TRANSPORTATION' => __('toes.sectorial_dimensions.transportation'),
57              'CONSUMER' => __('toes.sectorial_dimensions.consumer'),
58              'GENERALIT' => __('toes.sectorial_dimensions.general_it'),
59              'RESEARCHANDEDUCATION' => __('toes.sectorial_dimensions.research_and_education'),
60              'OTHERGENERALINDUSTRIES' => __('toes.sectorial_dimensions.other_general_industries'),
61              'SECTORINDEPENDENT' => __('toes.sectorial_dimensions.sector_independent'),
62              'NONE' => __('toes.sectorial_dimensions.none'),
63              default => '',
64          };
65      }
66  
67      public static function getTranslationByValue(string $value)
68      {
69          $key = array_search($value, array_column(SectorialDimensionsEnum::cases(), 'value', 'name'));
70          return self::getTranslation($key);
71      }
72  }