MoyenEnum.php 1.74 KB
Newer Older
1 2 3 4 5 6
<?php

namespace App\Enum;

abstract class MoyenEnum
{
7 8 9 10
    const MOYEN_CB          = "cb";
    const MOYEN_ESPECE      = "espece";
    const MOYEN_CHEQUE      = "cheque";
    const MOYEN_VIREMENT    = "virement";
Julien Jorry committed
11
    const MOYEN_TRANSFERT   = "transfert";
12 13 14
    const MOYEN_HELLOASSO   = "helloasso";
    const MOYEN_MLC         = "mlc";
    const MOYEN_AUTRE       = "autre";
15
    const MOYEN_VENTE       = "vente";
16
    const MOYEN_RETRAIT     = "retrait";
17

18 19 20

    /** @var array user friendly named type */
    protected static $typeName = [
21 22 23 24
        self::MOYEN_CB          => 'Carte bancaire',
        self::MOYEN_ESPECE      => 'Espèce',
        self::MOYEN_CHEQUE      => 'Chèque',
        self::MOYEN_VIREMENT    => 'Virement',
Julien Jorry committed
25
        self::MOYEN_TRANSFERT   => 'Transfert',
26 27 28
        self::MOYEN_HELLOASSO   => 'HelloAsso',
        self::MOYEN_MLC         => 'MLC',
        self::MOYEN_AUTRE       => 'Autre',
29
        self::MOYEN_VENTE       => 'Vente',
30
        self::MOYEN_RETRAIT     => 'Retrait',
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    ];

    /**
     * @param  string $typeShortName
     * @return string
     */
    public static function getTypeName($typeShortName)
    {
        if (!isset(static::$typeName[$typeShortName])) {
            return "Unknown type ($typeShortName)";
        }

        return static::$typeName[$typeShortName];
    }

    /**
     * @return array<string>
     */
    public static function getAvailableTypes()
    {
        return [
            self::MOYEN_CB,
            self::MOYEN_ESPECE,
            self::MOYEN_CHEQUE,
            self::MOYEN_VIREMENT,
Julien Jorry committed
56
            self::MOYEN_TRANSFERT,
57 58
            self::MOYEN_HELLOASSO,
            self::MOYEN_MLC,
59
            self::MOYEN_AUTRE,
60 61
            self::MOYEN_VENTE,
            self::MOYEN_RETRAIT
62 63 64
        ];
    }
}