reapers::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Importance

Changes 7
Bugs 3 Features 1
Metric Value
cc 1
eloc 11
c 7
b 3
f 1
nc 1
nop 7
dl 17
loc 17
rs 9.4285
1
<?php
2
3
namespace Sovereign\Plugins\onVoice;
4
5
use Discord\Discord;
6
use Discord\Parts\Channel\Channel;
7
use Discord\Parts\Channel\Message;
8
use Discord\Voice\VoiceClient;
9
use Discord\WebSockets\WebSocket;
10
use Monolog\Logger;
11
use Sovereign\Lib\cURL;
12
13 View Code Duplication
class reapers
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
0 ignored issues
show
Unused Code introduced by
The parameter $curl is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    {
17
        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18
            $guildID = $message->getChannelAttribute()->guild_id;
19
            // Add this audio stream to the array of audio streams
20
            $audioStreams[$guildID] = $vc;
21
            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
22
                $vc->setBitrate(128000);
23
                $number = mt_rand(1, 23);
24
                $file = __DIR__ . "/../../../sounds/reapers/{$number}.mp3";
25
                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
26
                    unset($audioStreams[$guildID]);
27
                    $vc->close();
28
                });
29
            });
30
        });
31
    }
32
}
33