<commit_before>//
//  Copyright RevenueCat Inc. All Rights Reserved.
//
//  Licensed under the MIT License (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      https://opensource.org/licenses/MIT
//
//  Purchases.swift
//
//  Created by <NAME> on 8/18/21.
//

// swiftlint:disable file_length type_body_length
import Foundation
import StoreKit

// MARK: Block definitions
/**
 Completion block for ``Purchases/purchase(product:completion:)``
 */
public typealias PurchaseCompletedBlock = (StoreTransaction?, CustomerInfo?, Error?, Bool) -> Void

/**
 Deferred block for ``Purchases/shouldPurchasePromoProduct(_:defermentBlock:)``
 */
public typealias DeferredPromotionalPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void

/**
 * `Purchases` is the entry point for RevenueCat.framework. It should be instantiated as soon as your app has a unique
 * user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random
 * user identifier.
 *  - Warning: Only one instance of Purchases should be instantiated at a time! Use a configure method to let the
 *  framework handle the singleton instance for you.
 */
@objc(RCPurchases) public class Purchases: NSObject {

#if DEBUG
#warning(
    """
    You're using a beta release (4.0.0-rc.1). If that's not intentional, you'll want to point to one of the \
    3.x release tags, or a specific branch instead of `main` see https://rev.cat/v4rmd for more information.
    """
    )
#endif

    /// Returns the already configured instance of `Purchases`.
    /// - Note: this method will crash with `fatalError` if `Purchases` has not been initialized through `configure()`.
    ///         If there's a chance that may have not happened yet, you can use ``isConfigured``
    ///         to check if it's safe to call.
    /// - SeeAlso: ``isConfigured``.
    @objc(sharedPurchases)
    public static var shared: Purchases {
        guard let purchases = purchases else {
            fatalError(Strings.purchase.purchases_nil.description)
        }

        return purchases
    }
    private static var purchases: Purchases?

    /// Returns `true` if RevenueCat has already been intialized through `configure()`.
    @objc public static var isConfigured: Bool { purchases != nil }

    /**
     * Delegate for `Purchases` instance. The delegate is responsible for handling promotional product purchases and
     * changes to customer information.
     */
    @objc public var delegate: PurchasesDelegate? {
        get { privateDelegate }
        set {
            guard newValue !== privateDelegate else {
                Logger.warn(Strings.purchase.purchases_delegate_set_multiple_times)
                return
            }
<commit_msg>`Purchases.shared`: changed `note to `warning` (#1247)<commit_after>//
//  Copyright RevenueCat Inc. All Rights Reserved.
//
//  Licensed under the MIT License (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      https://opensource.org/licenses/MIT
//
//  Purchases.swift
//
//  Created by <NAME> on 8/18/21.
//

// swiftlint:disable file_length type_body_length
import Foundation
import StoreKit

// MARK: Block definitions
/**
 Completion block for ``Purchases/purchase(product:completion:)``
 */
public typealias PurchaseCompletedBlock = (StoreTransaction?, CustomerInfo?, Error?, Bool) -> Void

/**
 Deferred block for ``Purchases/shouldPurchasePromoProduct(_:defermentBlock:)``
 */
public typealias DeferredPromotionalPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void

/**
 * `Purchases` is the entry point for RevenueCat.framework. It should be instantiated as soon as your app has a unique
 * user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random
 * user identifier.
 *  - Warning: Only one instance of Purchases should be instantiated at a time! Use a configure method to let the
 *  framework handle the singleton instance for you.
 */
@objc(RCPurchases) public class Purchases: NSObject {

#if DEBUG
#warning(
    """
    You're using a beta release (4.0.0-rc.1). If that's not intentional, you'll want to point to one of the \
    3.x release tags, or a specific branch instead of `main` see https://rev.cat/v4rmd for more information.
    """
    )
#endif

    /// Returns the already configured instance of `Purchases`.
    /// - Warning: this method will crash with `fatalError` if `Purchases` has not been
    ///            initialized through `configure()`.
    ///            If there's a chance that may have not happened yet, you can use ``isConfigured``
    ///            to check if it's safe to call.
    /// - SeeAlso: ``isConfigured``.
    @objc(sharedPurchases)
    public static var shared: Purchases {
        guard let purchases = purchases else {
            fatalError(Strings.purchase.purchases_nil.description)
        }

        return purchases
    }
    private static var purchases: Purchases?

    /// Returns `true` if RevenueCat has already been intialized through `configure()`.
    @objc public static var isConfigured: Bool { purchases != nil }

    /**
     * Delegate for `Purchases` instance. The delegate is responsible for handling promotional product purchases and
     * changes to customer information.
     */
    @objc public var delegate: PurchasesDelegate? {
        get { privateDelegate }
        set {
            guard newValue !== privateDelegate else {
                Logger.warn(Strings.purchase.purchases_delegate_set_multiple_times)
                return
            }

{'fraction_non_alphanumeric': 0.09379912663755459, 'fraction_numerical': 0.004541484716157205, 'mean_word_length': 2.927297668038409, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3501217', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1522, 'n_words': 611}