<commit_before><?php
/**
 * Pushy: Pushover PHP Client
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2013 <NAME>
 * @license   http://github.com/sqmk/Pushy/wiki/License
 */

namespace Pushy\Command;

use Pushy\Message;
use Pushy\Client;
use Pushy\Transport\RequestMessage;

/**
 * Send message command
 */
class SendMessage implements CommandInterface
{
    /**
     * Message object
     *
     * @var Message
     */
    protected $message;

    /**
     * Instantiates a send message command
     *
     * @param Message $message Message object
     */
    public function __construct(Message $message)
    {
        $this->message = $message;
    }

    /**
     * Send command
     *
     * @param Client $client Pushy client
     *
     * @return bool true if valid, false if not
     */
    public function send(Client $client)
    {
        // Init api params
        $apiParams = array_merge(
            [
                'token'     => $client->getApiToken(),
                'user'      => $this->message->getUser()->getId(),
                'device'    => $this->message->getUser()->getDeviceName(),
                'message'   => $this->message->getMessage(),
                'title'     => $this->message->getTitle(),
                'url'       => $this->message->getUrl(),
                'url_title' => $this->message->getUrlTitle(),
                'timestamp' => $this->message->getTimestamp(),
                'sound'     => (string) $this->message->getSound(),
            ],
            $this->message->getPriority()->getApiParameters()
        );

        // Create request message
        $requestMessage = (new RequestMessage)
            ->setMethod('POST')
            ->setPath('messages.json');

        // Set API params
        foreach ($apiParams as $param => $value) {
            // Skip param if null
            if ($value === null) {
                continue;
            }

            $requestMessage->setQueryParam($param, $value);
        }

        // Send request
        $response = $client->getTransport()->sendRequest($requestMessage);

        return $response;
    }
}<commit_msg>GitHub #8 - Send receipt on send message if there is one<commit_after><?php
/**
 * Pushy: Pushover PHP Client
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2013 <NAME>
 * @license   http://github.com/sqmk/Pushy/wiki/License
 */

namespace Pushy\Command;

use Pushy\Message;
use Pushy\Client;
use Pushy\Transport\RequestMessage;

/**
 * Send message command
 */
class SendMessage implements CommandInterface
{
    /**
     * Message object
     *
     * @var Message
     */
    protected $message;

    /**
     * Instantiates a send message command
     *
     * @param Message $message Message object
     */
    public function __construct(Message $message)
    {
        $this->message = $message;
    }

    /**
     * Send command
     *
     * @param Client $client Pushy client
     *
     * @return null|string null if no receipt, string if there is
     */
    public function send(Client $client)
    {
        // Init api params
        $apiParams = array_merge(
            [
                'token'     => $client->getApiToken(),
                'user'      => $this->message->getUser()->getId(),
                'device'    => $this->message->getUser()->getDeviceName(),
                'message'   => $this->message->getMessage(),
                'title'     => $this->message->getTitle(),
                'url'       => $this->message->getUrl(),
                'url_title' => $this->message->getUrlTitle(),
                'timestamp' => $this->message->getTimestamp(),
                'sound'     => (string) $this->message->getSound(),
            ],
            $this->message->getPriority()->getApiParameters()
        );

        // Create request message
        $requestMessage = (new RequestMessage)
            ->setMethod('POST')
            ->setPath('messages.json');

        // Set API params
        foreach ($apiParams as $param => $value) {
            // Skip param if null
            if ($value === null) {
                continue;
            }

            $requestMessage->setQueryParam($param, $value);
        }

        // Send request
        $response = $client->getTransport()->sendRequest($requestMessage);

        // Return receipt if there is one
        if (isset($response->receipt)) {
            return $response->receipt;
        }
    }
}
{'fraction_non_alphanumeric': 0.1426968813102984, 'fraction_numerical': 0.002019295490240072, 'mean_word_length': 1.7793017456359101, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 89, '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': '1066023', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1199, 'n_words': 276}