<?php

namespace App\Domain\Payroll\Enums;

/** What a salary component does to the pay packet (§52). */
enum ComponentType: string
{
    case Earning = 'earning';
    case Deduction = 'deduction';
    case EmployerContribution = 'employer_contribution';
    case Informational = 'informational';

    public function label(): string
    {
        return match ($this) {
            self::Earning => 'Earning',
            self::Deduction => 'Deduction',
            self::EmployerContribution => 'Employer Contribution',
            self::Informational => 'Informational',
        };
    }

    /** Whether this component moves the employee's net pay. */
    public function affectsNetPay(): bool
    {
        return in_array($this, [self::Earning, self::Deduction], true);
    }

    /** @return array<int, string> */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
