public static function build(array $array) {
        if (array_key_exists("type", $array) && in_array($array["type"], self::$availableTypes)) {
            switch ($array["type"]) {
                case Payment::TYPE_CREDIT:
                    return new CreditCard($array);
                    break;

                case Payment::TYPE_BOLETO:
                    return new Boleto($array);
                    break;

                case Payment::TYPE_DEBIT:
                case Payment::TYPE_TRANSFER:
                case Payment::TYPE_VOUCHER:
                    return new Payment($array);
                    break;

                default:  // Exception
            }
        }
        throw new \InvalidArgumentException("Array must contain a valid 'type' field");
    }