Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
TransactionType
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
4 / 4
12
100.00% covered (success)
100.00%
1 / 1
 translatedName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 translationKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 cssClass
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
5
 cssClassPdf
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
5
1<?php
2
3declare(strict_types=1);
4
5namespace App\Type;
6
7use Symfony\Component\Translation\TranslatableMessage;
8
9enum TransactionType: string
10{
11    case rent = '1';
12    case payment = '2';
13    case initial = '3';
14    case adjustment = '4';
15
16    public function translatedName(): TranslatableMessage
17    {
18        return new TranslatableMessage($this->translationKey());
19    }
20
21    public function translationKey(): string
22    {
23        return 'TRANSACTION_TYPE_'.strtoupper($this->name);
24    }
25
26    public function cssClass(): string
27    {
28        return match ($this) {
29            self::rent => 'table-success',
30            self::payment => '',
31            self::initial => 'table-info',
32            self::adjustment => 'table-warning',
33        };
34    }
35
36    public function cssClassPdf(): string
37    {
38        return match ($this) {
39            self::rent => 'rent',
40            self::payment => '',
41            self::initial => 'initial',
42            self::adjustment => 'adjustment',
43        };
44    }
45}