summaryrefslogtreecommitdiff
path: root/src/Support/ResourceType.php
blob: 3583824bff70b3993dbbe306f49efcdeda137b35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

namespace App\Support;

enum ResourceType: string
{
  case Wood = 'Wood';
  case Clay = 'Clay';
  case Iron = 'Iron';
  case Food = 'Food';

  public static function asProperties(): array
  {
    return array_map(function (ResourceType $case) {
      return strtolower($case->value);
    }, self::cases());
  }

  public static function asPropertiesForBuildings(): array
  {
    $resourceTypes = self::asProperties();
    $resourceTypes = array_filter($resourceTypes, function ($resourceType) {
      return $resourceType !== strtolower(self::Food->value);
    });

    return $resourceTypes;
  }
}