<commit_before><?php

namespace Moccalotto\Ssh;

class Valid 
{
    /**
     * Check if param is a valid TCP port number.
     *
     * @param mixed $port The valaue to be checked.
     * @return boolean
     */
    public static function tcpPort($port)
    {
        if (false === filter_var($port, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 65535]])) {
            return false;
        }

        return true;
    }

    /**
     * Check if param is a valid stream resource.
     *
     * @param resource $resource The value to be checked.
     * @return boolean
     */
    public static function streamResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'stream') {
            return false;
        }

        $info = stream_get_meta_data($resource);
        if ($info['stream_type'] !== 'SSH2 Channel') {
            return false;
        }

        return true;
    }

    /**
     * Check if param is a valid SSH2 Session resource.
     *
     * @param mixed $resource The value to be checked.
     * @return boolean
     */
    public static function sshSessionResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'SSH2 Session') {
            return false;
        }

        return true;
    }


    public static function sshSftpResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'SSH2 SFTP') {
            return false;
        }

        return true;
    }
}
<commit_msg>Commentary<commit_after><?php

namespace Moccalotto\Ssh;

class Valid 
{
    /**
     * Check if param is a valid TCP port number.
     *
     * @param mixed $port The valaue to be checked.
     * @return boolean
     */
    public static function tcpPort($port)
    {
        if (false === filter_var($port, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 65535]])) {
            return false;
        }

        return true;
    }

    /**
     * Check if param is a valid stream resource.
     *
     * @param resource $resource The value to be checked.
     * @return boolean
     */
    public static function streamResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'stream') {
            return false;
        }

        $info = stream_get_meta_data($resource);
        if ($info['stream_type'] !== 'SSH2 Channel') {
            return false;
        }

        return true;
    }

    /**
     * Check if param is a valid SSH2 Session resource.
     *
     * @param mixed $resource The value to be checked.
     * @return boolean
     */
    public static function sshSessionResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'SSH2 Session') {
            return false;
        }

        return true;
    }

    /**
     * Check if param is a valid SSH2 SFTP Resource
     *
     * @param mixed $resource THe value to be checked.
     * @return boolean
     */
    public static function sshSftpResource($resource)
    {
        if (!is_resource($resource)) {
            return false;
        }

        if (get_resource_type($resource) !== 'SSH2 SFTP') {
            return false;
        }

        return true;
    }
}

{'fraction_non_alphanumeric': 0.11205193338978267, 'fraction_numerical': 0.0059271803556308214, 'mean_word_length': 1.7622759158222916, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5337548', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1002, 'n_words': 285}