Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Category
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
3 / 3
18
100.00% covered (success)
100.00%
1 / 1
 label
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
6
 icon
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
6
 color
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
6
1<?php
2
3declare(strict_types=1);
4
5namespace App\Expense\Domain;
6
7/**
8 * The fixed set of expense categories: this enum is the source of valid values.
9 * Each case also carries its default presentation (Spanish label, PrimeIcon,
10 * accent colour); an admin may override any of it per category through
11 * CategorySetting, which stores only what was actually changed.
12 */
13enum Category: string
14{
15    case FOOD = 'FOOD';
16    case TRANSPORT = 'TRANSPORT';
17    case LODGING = 'LODGING';
18    case ACTIVITIES = 'ACTIVITIES';
19    case OTHER = 'OTHER';
20
21    public function label(): string
22    {
23        return match ($this) {
24            self::FOOD => 'Comida',
25            self::TRANSPORT => 'Transporte',
26            self::LODGING => 'Alojamiento',
27            self::ACTIVITIES => 'Actividades',
28            self::OTHER => 'Otros',
29        };
30    }
31
32    public function icon(): string
33    {
34        return match ($this) {
35            self::FOOD => 'pi pi-shopping-cart',
36            self::TRANSPORT => 'pi pi-car',
37            self::LODGING => 'pi pi-building',
38            self::ACTIVITIES => 'pi pi-ticket',
39            self::OTHER => 'pi pi-tag',
40        };
41    }
42
43    /** Tints the circular category icon in the UI; OTHER stays on the garnet brand. */
44    public function color(): string
45    {
46        return match ($this) {
47            self::FOOD => '#c9742e',
48            self::TRANSPORT => '#3f72a8',
49            self::LODGING => '#b5546b',
50            self::ACTIVITIES => '#4f8a6b',
51            self::OTHER => '#8c1d2f',
52        };
53    }
54}