Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the group api #2

Open
marein opened this issue Oct 1, 2017 · 0 comments
Open

Implement the group api #2

marein opened this issue Oct 1, 2017 · 0 comments

Comments

@marein
Copy link
Owner

marein commented Oct 1, 2017

Nchan has a concept named groups. A group configuration can be shown and can be changed.

Suggested implementation / collaborators

Code documentation and use statements has been removed for readability.

This class wraps the group api.

<?php

namespace Marein\Nchan\Api;

final class Group
{
    private $groupUrl;

    private $client;

    public function __construct(Url $groupUrl, Client $client)
    {
        $this->groupUrl = $groupUrl;
        $this->client = $client;
    }

    public function configuration(): GroupInformation
    {
        // Create and return value object for group information.
    }

    public function configure(): GroupConfigurator
    {
        return new GroupConfigurator($this->groupUrl, $this->client);
    }
}

This class acts like a builder for the group configuration. The configuration is sent when the configurate method is called.

<?php

namespace Marein\Nchan\Api;

final class GroupConfigurator
{
    private $groupUrl;

    private $client;

    public function __construct(Url $groupUrl, Client $client)
    {
        $this->groupUrl = $groupUrl;
        $this->client = $client;
    }

    public function changeMaximumNumberOfChannels(
        int $maximumNumberOfChannels
    ): GroupConfigurator
    {
        $this->groupUrl = $this->groupUrl->appendQueryString(
            'max_channels',
            $maximumNumberOfChannels
        );

        return $this;
    }

    public function changeMaximumNumberOfSubscribers(
        int $maximumNumberOfSubscribers
    ): GroupConfigurator
    {
        $this->groupUrl = $this->groupUrl->appendQueryString(
            'max_subs',
            $maximumNumberOfSubscribers
        );

        return $this;
    }

    public function configurate(): void
    {
        // Send request with configured items
    }
}
@marein marein added this to the 1.1.0 milestone Oct 1, 2017
@marein marein self-assigned this Oct 1, 2017
@marein marein removed this from the 1.1.0 milestone Apr 9, 2019
@marein marein added the on hold label Apr 9, 2019
@marein marein removed their assignment Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant