<commit_before><?php
/**
 * Created by PhpStorm.
 * User: magroski
 * Date: 09/10/17
 * Time: 16:23
 */

namespace Frogg\Services;

use Aws\Credentials\Credentials;
use Aws\Sqs\SqsClient as AmazonSqsClient;

class SqsClient
{
    protected $sqsClient;
    protected $queueUrl;

    /**
     * SqsClient constructor.
     *
     * @param array $config Config array expect the following keys:
     *                      AWS_ACCESS_KEY
     *                      AWS_SECRET_KEY
     *                      AWS_SQS_REGION
     *                      AWS_SQS_QUEUE_URL
     */
    public function __construct(array $config)
    {
        $credentialsInst = new Credentials(
            $config['AWS_ACCESS_KEY'],
            $config['AWS_SECRET_KEY']
        );

        $this->sqsClient = new AmazonSqsClient([
            'credentials' => $credentialsInst,
            'region'      => $config['AWS_SQS_REGION'],
            'version'     => 'latest',
        ]);
        $this->queueUrl  = $config['AWS_SQS_QUEUE_URL'];
    }

    /**
     * Sends a message to AWS SQS service
     *
     * @param string $message The content of the message, must be text or a json_encoded array
     */
    public function sendMessage(string $message)
    {
        $this->sqsClient->sendMessage([
            'MessageBody' => $message,
            'QueueUrl'    => $this->queueUrl,
        ]);
    }

}<commit_msg>adds delayed message functionality<commit_after><?php

namespace Frogg\Services;

use Aws\Credentials\Credentials;
use Aws\Sqs\SqsClient as AmazonSqsClient;

class SqsClient
{
    protected $sqsClient;
    protected $queueUrl;

    /**
     * SqsClient constructor.
     *
     * @param array $config Config array expect the following keys:
     *                      AWS_ACCESS_KEY
     *                      AWS_SECRET_KEY
     *                      AWS_SQS_REGION
     *                      AWS_SQS_QUEUE_URL
     */
    public function __construct(array $config)
    {
        $credentialsInst = new Credentials(
            $config['AWS_ACCESS_KEY'],
            $config['AWS_SECRET_KEY']
        );

        $this->sqsClient = new AmazonSqsClient([
            'credentials' => $credentialsInst,
            'region'      => $config['AWS_SQS_REGION'],
            'version'     => 'latest',
        ]);
        $this->queueUrl  = $config['AWS_SQS_QUEUE_URL'];
    }

    /**
     * Sends a message to AWS SQS service
     *
     * @param string $message The content of the message, must be text or a json_encoded array
     */
    public function sendMessage(string $message)
    {
        $this->sqsClient->sendMessage([
            'MessageBody' => $message,
            'QueueUrl'    => $this->queueUrl,
        ]);
    }

    /**
     * Sends a message to AWS SQS service
     *
     * @param string $message The content of the message, must be text or a json_encoded array
     * @param int    $delay   Delay in seconds. Min: 0 Max: 900 (15 minutes)
     */
    public function sendDelayedMessage(string $message, int $delay = 0)
    {
        $delay = max(0, $delay);
        $delay = min(900, $delay);
        $this->sqsClient->sendMessage([
            'DelaySeconds' => $delay,
            'MessageBody'  => $message,
            'QueueUrl'     => $this->queueUrl,
        ]);
    }
}

{'fraction_non_alphanumeric': 0.10990009082652134, 'fraction_numerical': 0.006357856494096276, 'mean_word_length': 1.838487972508591, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, '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': '2730563', 'n_tokens_mistral': 1018, 'n_tokens_neox': 994, 'n_words': 228}