<commit_before><?php

namespace SA;

class SnsHandler {
    /** AWS DynamoDB handler **/
    private $ddb;

    /** AWS region for SQS **/
    private $region;

    /** AWS SNS handler **/
    private $sns;

    public function __construct($region = false) {
        if (!$region &&
            !($region = getenv("AWS_DEFAULT_REGION"))) {
            throw new \Exception("Set 'AWS_DEFAULT_REGION' environment variable!");
        }

        $this->region = $region;

        $this->sns = new \Aws\Sns\SnsClient([
            "region" => $region,
            "version" => "latest",
        ]);

        $this->ddb = new \Aws\DynamoDb\DynamoDbClient([
            "region" => $region,
            "version" => "latest",
        ]);
    }

    // $alert contains default keys handled by both Apple and Google.
    // We follow the Google formatting:
    // https://developers.google.com/cloud-messaging/http-server-ref#notification-payload-support
    public function publishToEndpoint(
        $endpoint,
        $alert,
        $data,
        $options,
        $providers = ["GCM", "APNS", "APNS_SANDBOX"],
        $default = "",
        $save = true,
        $identity_id = null) {
        $message = [
            "default" => $default,
        ];

        // Iterate over all providers and inject custom alert message in global message
        foreach ($providers as $provider) {
            if (!method_exists($this, $provider)) {<commit_msg>add default provider for aws clients<commit_after><?php

namespace SA;

use Aws\Credentials\CredentialProvider;

class SnsHandler {
    /** AWS DynamoDB handler **/
    private $ddb;

    /** AWS region for SQS **/
    private $region;

    /** AWS SNS handler **/
    private $sns;

    public function __construct($region = false) {
        if (!$region &&
            !($region = getenv("AWS_DEFAULT_REGION"))) {
            throw new \Exception("Set 'AWS_DEFAULT_REGION' environment variable!");
        }

        $this->region = $region;

        $provider = CredentialProvider::defaultProvider();

        $this->sns = new \Aws\Sns\SnsClient([
            "region" => $region,
            "version" => "latest",
            "credentials" => $provider
        ]);

        $this->ddb = new \Aws\DynamoDb\DynamoDbClient([
            "region" => $region,
            "version" => "latest",
            "credentials" => $provider
        ]);
    }

    // $alert contains default keys handled by both Apple and Google.
    // We follow the Google formatting:
    // https://developers.google.com/cloud-messaging/http-server-ref#notification-payload-support
    public function publishToEndpoint(
        $endpoint,
        $alert,
        $data,
        $options,
        $providers = ["GCM", "APNS", "APNS_SANDBOX"],
        $default = "",
        $save = true,
        $identity_id = null) {
        $message = [
            "default" => $default,
        ];

        // Iterate over all providers and inject custom alert message in global message
        foreach ($providers as $provider) {
            if (!method_exists($this, $provider)) {
{'fraction_non_alphanumeric': 0.13695090439276486, 'fraction_numerical': 0.0, 'mean_word_length': 2.027370478983382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '1511215', 'n_tokens_mistral': 900, 'n_tokens_neox': 879, 'n_words': 223}