<commit_before><?php

/*
 * This file is part of PhuninNode.
 *
 ** (c) 2013 - 2014 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WyriHaximus\PhuninNode;

/**
 * Class ConnectionContext
 * @package WyriHaximus\PhuninNode
 */
class ConnectionContext
{
    /**
     * The greeting munin expects
     */
    const GREETING = "# munin node at HOSTNAME\n";

    /**
     * The timeout after which we disconnection for no data transmission
     */
    const CONNECTION_TIMEOUT = 60;

    /**
     * @var \React\Socket\Connection
     */
    private $conn;

    /**
     * @var Node
     */
    private $node;

    /**
     * @var array
     */
    private $commandMap = [];

    private $timeoutTimer;

    /**
     * @param \React\Socket\Connection $conn
     * @param Node $node
     */
    public function __construct(\React\Socket\Connection $conn, Node $node)
    {
        $this->conn = $conn;
        $this->node = $node;
        $this->loop = $node->getLoop();

        $this->conn->on('data', [$this, 'onData']);
        $this->conn->on('close', [$this, 'onClose']);

        $this->commandMap['list'] = [$this, 'onList'];
        $this->commandMap['nodes'] = [$this, 'onNodes'];
        $this->commandMap['version'] = [$this, 'onVersion'];
        $this->commandMap['config'] = [$this, 'onConfig'];
        $this->commandMap['fetch'] = [$this, 'onFetch'];
        $this->commandMap['quit'] = [$this, 'onQuit'];

        $this->write(self::GREETING);
    }

    /**
     * Write data to the connection<commit_msg>Docblock and missing property<commit_after><?php

/*
 * This file is part of PhuninNode.
 *
 ** (c) 2013 - 2014 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WyriHaximus\PhuninNode;

/**
 * Class ConnectionContext
 * @package WyriHaximus\PhuninNode
 */
class ConnectionContext
{
    /**
     * The greeting munin expects
     */
    const GREETING = "# munin node at HOSTNAME\n";

    /**
     * The timeout after which we disconnection for no data transmission
     */
    const CONNECTION_TIMEOUT = 60;

    /**
     * @var \React\Socket\Connection
     */
    private $conn;

    /**
     * @var Node
     */
    private $node;

    /**
     * @var array
     */
    private $commandMap = [];

    /**
     * @var \React\EventLoop\Timer\TimerInterface
     */
    private $timeoutTimer;

    /**
     * @var \React\EventLoop\LoopInterface
     */
    private $loop;

    /**
     * @param \React\Socket\Connection $conn
     * @param Node $node
     */
    public function __construct(\React\Socket\Connection $conn, Node $node)
    {
        $this->conn = $conn;
        $this->node = $node;
        $this->loop = $node->getLoop();

        $this->conn->on('data', [$this, 'onData']);
        $this->conn->on('close', [$this, 'onClose']);

        $this->commandMap['list'] = [$this, 'onList'];
        $this->commandMap['nodes'] = [$this, 'onNodes'];
        $this->commandMap['version'] = [$this, 'onVersion'];
        $this->commandMap['config'] = [$this, 'onConfig'];
        $this->commandMap['fetch'] = [$this, 'onFetch'];
        $this->commandMap['quit'] = [$this, 'onQuit'];

        $this->write(self::GREETING);
    }

    /**
     * Write data to the connection
{'fraction_non_alphanumeric': 0.1671071953010279, 'fraction_numerical': 0.005873715124816446, 'mean_word_length': 2.3856858846918487, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, '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': '5686879', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1050, 'n_words': 254}