<commit_before><?php

namespace Marein\Nchan;

use Marein\Nchan\Api\Channel;
use Marein\Nchan\Api\Status;
use Marein\Nchan\Http\Adapter\FileGetContents;
use Marein\Nchan\Http\Client;
use Marein\Nchan\Http\Url;

final class Nchan
{
    /**
     * @var string
     */
    private $baseUrl;

    /**
     * @var Client
     */
    private $client;

    /**
     * Nchan constructor.
     *
     * @param string      $baseUrl
     * @param Client|null $client
     */
    public function __construct(string $baseUrl, Client $client = null)
    {
        $this->baseUrl = new Url($baseUrl);
        $client = $client ?: new FileGetContents();
        $this->client = $client;
    }

    /**
     * Create the api for the given channel name.
     *
     * @param string $name
     *
     * @return Channel
     */
    public function channel(string $name): Channel
    {
        return new Channel($this->baseUrl->append($name), $this->client);
    }

    /**
     * Create the api for the given status path. The path must be configured with the "nchan_stub_status;" directive.<commit_msg>Refactor for readability<commit_after><?php

namespace Marein\Nchan;

use Marein\Nchan\Api\Channel;
use Marein\Nchan\Api\Status;
use Marein\Nchan\Http\Adapter\FileGetContents;
use Marein\Nchan\Http\Client;
use Marein\Nchan\Http\Url;

final class Nchan
{
    /**
     * @var string
     */
    private $baseUrl;

    /**
     * @var Client
     */
    private $client;

    /**
     * Nchan constructor.
     *
     * @param string      $baseUrl
     * @param Client|null $client
     */
    public function __construct(string $baseUrl, Client $client = null)
    {
        $this->baseUrl = new Url($baseUrl);
        $this->client = $client ?? new FileGetContents();
    }

    /**
     * Create the api for the given channel name.
     *
     * @param string $name
     *
     * @return Channel
     */
    public function channel(string $name): Channel
    {
        return new Channel($this->baseUrl->append($name), $this->client);
    }

    /**
     * Create the api for the given status path. The path must be configured with the "nchan_stub_status;" directive.
{'fraction_non_alphanumeric': 0.12465116279069767, 'fraction_numerical': 0.0, 'mean_word_length': 2.3194444444444446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '53274', 'n_tokens_mistral': 685, 'n_tokens_neox': 678, 'n_words': 173}