<commit_before><?php

declare(strict_types=1);

namespace Pnz\MattermostClient\Api;

use Pnz\MattermostClient\Exception\InvalidArgumentException;
use Pnz\MattermostClient\Model\Channel\Channel;
use Pnz\MattermostClient\Model\Channel\ChannelMember;
use Pnz\MattermostClient\Model\Channel\ChannelMembers;
use Pnz\MattermostClient\Model\Channel\ChannelStats;
use Pnz\MattermostClient\Model\Post\Posts;
use Pnz\MattermostClient\Model\Status;
use Psr\Http\Message\ResponseInterface;

final class ChannelsApi extends HttpApi
{
    /**
     * Returns an channel by its ID.
     *
     * @param string $channelId
     *
     * @return Channel|ResponseInterface
     */
    public function getChannelById(string $channelId)
    {
        if (empty($channelId)) {
            throw new InvalidArgumentException('Id can not be empty');
        }

        $response = $this->httpGet(sprintf('/channels/%s', $channelId));

        return $this->handleResponse($response, Channel::class);
    }

    /**
     * Returns an channel by its ID.
     *
     * @param string $teamId
     * @param string $channelName
     *
     * @return Channel|ResponseInterface
     */
    public function getChannelByName(string $teamId, string $channelName)
    {
        if (empty($teamId) || empty($channelName)) {
            throw new InvalidArgumentException('Team ID and channel name can not be empty');
        }

        $response = $this->httpGet(sprintf('/teams/%s/channels/name/%s', $teamId, $channelName));

        return $this->handleResponse($response, Channel::class);<commit_msg>Allow getChannelByName() to accept GET parameters<commit_after><?php

declare(strict_types=1);

namespace Pnz\MattermostClient\Api;

use Pnz\MattermostClient\Exception\InvalidArgumentException;
use Pnz\MattermostClient\Model\Channel\Channel;
use Pnz\MattermostClient\Model\Channel\ChannelMember;
use Pnz\MattermostClient\Model\Channel\ChannelMembers;
use Pnz\MattermostClient\Model\Channel\ChannelStats;
use Pnz\MattermostClient\Model\Post\Posts;
use Pnz\MattermostClient\Model\Status;
use Psr\Http\Message\ResponseInterface;

final class ChannelsApi extends HttpApi
{
    /**
     * Returns an channel by its ID.
     *
     * @param string $channelId
     *
     * @return Channel|ResponseInterface
     */
    public function getChannelById(string $channelId)
    {
        if (empty($channelId)) {
            throw new InvalidArgumentException('Id can not be empty');
        }

        $response = $this->httpGet(sprintf('/channels/%s', $channelId));

        return $this->handleResponse($response, Channel::class);
    }

    /**
     * Returns a channel given the team ID and the channel name.
     *
     * @param array $parameters Associative array of additional parameters for the request:
     *                          - 'include_deleted'=>'true': allow to fetch deleted channels too
     *
     * @return Channel|ResponseInterface
     */
    public function getChannelByName(string $teamId, string $channelName, array $parameters = [])
    {
        if (empty($teamId) || empty($channelName)) {
            throw new InvalidArgumentException('Team ID and channel name can not be empty');
        }

        $response = $this->httpGet(
            sprintf('/teams/%s/channels/name/%s', $teamId, $channelName),
            $parameters
        );

        return $this->handleResponse($response, Channel::class);
{'fraction_non_alphanumeric': 0.11265113535830139, 'fraction_numerical': 0.0005897965202005308, 'mean_word_length': 3.2032218091697646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '5796305', 'n_tokens_mistral': 970, 'n_tokens_neox': 944, 'n_words': 217}