Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
25 / 25 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| DealStageKey | |
100.00% |
25 / 25 |
|
100.00% |
3 / 3 |
14 | |
100.00% |
1 / 1 |
| label | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
11 | |||
| isTerminal | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| defaultPipelineDefinition | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Sales\Domain\Enums; |
| 6 | |
| 7 | enum DealStageKey: string |
| 8 | { |
| 9 | case New = 'new'; |
| 10 | case Qualified = 'qualified'; |
| 11 | case VisitScheduled = 'visit_scheduled'; |
| 12 | case VisitDone = 'visit_done'; |
| 13 | case Negotiation = 'negotiation'; |
| 14 | case Proposal = 'proposal'; |
| 15 | case Documentation = 'documentation'; |
| 16 | case Contract = 'contract'; |
| 17 | case Won = 'won'; |
| 18 | case Lost = 'lost'; |
| 19 | |
| 20 | public function label(): string |
| 21 | { |
| 22 | return match ($this) { |
| 23 | self::New => 'Nova', |
| 24 | self::Qualified => 'Qualificado', |
| 25 | self::VisitScheduled => 'Visita Agendada', |
| 26 | self::VisitDone => 'Visita Realizada', |
| 27 | self::Negotiation => 'Negociação', |
| 28 | self::Proposal => 'Proposta', |
| 29 | self::Documentation => 'Documentação', |
| 30 | self::Contract => 'Contrato', |
| 31 | self::Won => 'Concluído', |
| 32 | self::Lost => 'Perdido', |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | public function isTerminal(): bool |
| 37 | { |
| 38 | return $this === self::Won || $this === self::Lost; |
| 39 | } |
| 40 | |
| 41 | /** @return list<array{key: string, name: string, position: int, is_won: bool, is_lost: bool, color: string}> */ |
| 42 | public static function defaultPipelineDefinition(): array |
| 43 | { |
| 44 | return [ |
| 45 | ['key' => self::New->value, 'name' => self::New->label(), 'position' => 1, 'is_won' => false, 'is_lost' => false, 'color' => '#64748b'], |
| 46 | ['key' => self::Qualified->value, 'name' => self::Qualified->label(), 'position' => 2, 'is_won' => false, 'is_lost' => false, 'color' => '#0ea5e9'], |
| 47 | ['key' => self::VisitScheduled->value, 'name' => self::VisitScheduled->label(), 'position' => 3, 'is_won' => false, 'is_lost' => false, 'color' => '#8b5cf6'], |
| 48 | ['key' => self::VisitDone->value, 'name' => self::VisitDone->label(), 'position' => 4, 'is_won' => false, 'is_lost' => false, 'color' => '#6366f1'], |
| 49 | ['key' => self::Negotiation->value, 'name' => self::Negotiation->label(), 'position' => 5, 'is_won' => false, 'is_lost' => false, 'color' => '#f59e0b'], |
| 50 | ['key' => self::Proposal->value, 'name' => self::Proposal->label(), 'position' => 6, 'is_won' => false, 'is_lost' => false, 'color' => '#f97316'], |
| 51 | ['key' => self::Documentation->value, 'name' => self::Documentation->label(), 'position' => 7, 'is_won' => false, 'is_lost' => false, 'color' => '#14b8a6'], |
| 52 | ['key' => self::Contract->value, 'name' => self::Contract->label(), 'position' => 8, 'is_won' => false, 'is_lost' => false, 'color' => '#10b981'], |
| 53 | ['key' => self::Won->value, 'name' => self::Won->label(), 'position' => 9, 'is_won' => true, 'is_lost' => false, 'color' => '#22c55e'], |
| 54 | ['key' => self::Lost->value, 'name' => self::Lost->label(), 'position' => 10, 'is_won' => false, 'is_lost' => true, 'color' => '#ef4444'], |
| 55 | ]; |
| 56 | } |
| 57 | } |