Code Duplication    Length = 57-61 lines in 2 locations

src/ritero/SDK/TwitchTV/Methods/Block.php 1 location

@@ 17-77 (lines=61) @@
14
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
15
 * @homepage https://github.com/jofner/Twitch-SDK
16
 */
17
class Block
18
{
19
    /** @var TwitchRequest */
20
    protected $request;
21
22
    const URI_BLOCK_USER = 'users/%s/blocks';
23
    const URI_BLOCK_TARGET = 'users/%s/blocks/%s';
24
25
    /**
26
     * Block constructor
27
     * @param TwitchRequest $request
28
     */
29
    public function __construct(TwitchRequest $request)
30
    {
31
        $this->request = $request;
32
    }
33
34
    /**
35
     * Returns a list of blocks
36
     *  - requires scope 'user_blocks_read'
37
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#get-usersuserblocks
38
     * @param string $user
39
     * @param string $queryString
40
     * @return \stdClass
41
     * @throws TwitchException
42
     */
43
    public function getBlocks($user, $queryString)
44
    {
45
        return $this->request->request(sprintf(self::URI_BLOCK_USER, $user) . $queryString);
46
    }
47
48
    /**
49
     * Adds $target to $user block list
50
     *  - requires scope 'user_blocks_edit'
51
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#put-usersuserblockstarget
52
     * @param string $user
53
     * @param string $target
54
     * @param string $queryString
55
     * @return \stdClass
56
     * @throws TwitchException
57
     */
58
    public function blockTarget($user, $target, $queryString)
59
    {
60
        return $this->request->request(sprintf(self::URI_BLOCK_TARGET, $user, $target) . $queryString, 'PUT');
61
    }
62
63
    /**
64
     * Removes $target from $user block list
65
     *  - requires scope 'user_blocks_edit'
66
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md#delete-usersuserblockstarget
67
     * @param string $user
68
     * @param string $target
69
     * @param string $queryString
70
     * @return \stdClass
71
     * @throws TwitchException
72
     */
73
    public function removeTarget($user, $target, $queryString)
74
    {
75
        return $this->request->request(sprintf(self::URI_BLOCK_TARGET, $user, $target) . $queryString, 'DELETE');
76
    }
77
}
78

src/ritero/SDK/TwitchTV/Methods/Subscription.php 1 location

@@ 17-73 (lines=57) @@
14
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
15
 * @homepage https://github.com/jofner/Twitch-SDK
16
 */
17
class Subscription
18
{
19
    /** @var TwitchRequest */
20
    protected $request;
21
22
    const URI_CHANNEL_SUBSCRIPTIONS = 'channels/%s/subscriptions';
23
    const URI_CHANNEL_SUBSCRIPTIONS_USER = 'channels/%s/subscriptions/%s';
24
    const URI_USER_SUBSCRIPTIONS_CHANNEL = 'users/%s/subscriptions/%s';
25
26
    public function __construct(TwitchRequest $request)
27
    {
28
        $this->request = $request;
29
    }
30
31
    /**
32
     * @description Returns an array of subscriptions who are subscribed to specified channel
33
     *  - requires scope 'channel_subscriptions'
34
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md#get-channelschannelsubscriptions
35
     * @param string $channel
36
     * @param string $queryString
37
     * @return \stdClass
38
     * @throws TwitchException
39
     */
40
    public function getSubscriptions($channel, $queryString)
41
    {
42
        return $this->request->request(sprintf(self::URI_CHANNEL_SUBSCRIPTIONS, $channel) . $queryString);
43
    }
44
45
    /**
46
     * Returns user object if that user is subscribed
47
     *  - requires scope 'channel_check_subscription' for channel
48
     * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/subscriptions.md#get-channelschannelsubscriptionsuser
49
     * @param string $channel
50
     * @param string $user
51
     * @param string $queryString
52
     * @return \stdClass
53
     * @throws TwitchException
54
     */
55
    public function getSubscribedUser($channel, $user, $queryString)
56
    {
57
        return $this->request->request(sprintf(self::URI_CHANNEL_SUBSCRIPTIONS_USER, $channel, $user) . $queryString);
58
    }
59
60
    /**
61
     * Returns a channel object that user subscribes to
62
     *  - requires scope 'user_subscriptions' for user
63
     * @param string $user
64
     * @param string $channel
65
     * @param string $queryString
66
     * @return \stdClass
67
     * @throws TwitchException
68
     */
69
    public function getSubscribedToChannel($user, $channel, $queryString)
70
    {
71
        return $this->request->request(sprintf(self::URI_USER_SUBSCRIPTIONS_CHANNEL, $user, $channel) . $queryString);
72
    }
73
}
74