nopolabs/yabot

View on GitHub
src/Slack/Client.php

Summary

Maintainability
B
4 hrs
Test Coverage

Client has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class Client
{
    use ConfigTrait;
    use LogTrait;

Severity: Minor
Found in src/Slack/Client.php - About 4 hrs to fix

    The class Client has 15 public methods. Consider refactoring Client to keep number of public methods under 10.
    Open

    class Client
    {
        use ConfigTrait;
        use LogTrait;
    
    
    Severity: Minor
    Found in src/Slack/Client.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            RealTimeClient $realTimeClient,
            Users $users,
            Bots $bots,
            Channels $channels,
            array $config = [],
    Severity: Minor
    Found in src/Slack/Client.php - About 45 mins to fix

      The class Client has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
      Wontfix

      class Client
      {
          use ConfigTrait;
          use LogTrait;
      
      
      Severity: Minor
      Found in src/Slack/Client.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

      Call to method ping from undeclared class \Slack\RealTimeClient
      Open

              return $this->getRealTimeClient()->ping();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method getUsername from undeclared class \Slack\User
      Open

              return $this->authedUser->getUsername();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of getUserByName() is undeclared type \Slack\User
      Open

          public function getUserByName($name)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Parameter $user has undeclared type \Slack\User
      Open

              $this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method apiCall from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->apiCall('chat.postMessage', $parameters);
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of getChannelById() is undeclared type \Slack\Channel
      Open

          public function getChannelById($channelId)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Return type of getChannelByName() is undeclared type \Slack\Channel
      Open

          public function getChannelByName($name)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method getAuthedUser from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Property \Nopolabs\Yabot\Slack\Client->authedUser has undeclared type \Slack\User
      Open

          protected $authedUser;
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method on from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Checking instanceof against undeclared class \Slack\ChannelInterface
      Open

              if ($channel instanceof ChannelInterface) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method disconnect from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->disconnect();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method getId from undeclared class \Slack\ChannelInterface
      Open

                  'channel' => $channel->getId(),
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of getBotByName() is undeclared type \Slack\Bot
      Open

          public function getBotByName($name)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method connect from undeclared class \Slack\RealTimeClient
      Open

              return $this->realTimeClient->connect();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Checking instanceof against undeclared class \Slack\ChannelInterface
      Open

              if ($channel instanceof ChannelInterface) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of connect() is undeclared type \React\Promise\PromiseInterface
      Open

          public function connect() : PromiseInterface
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method disconnect from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->disconnect();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Parameter $channel has undeclared type \Slack\ChannelInterface
      Open

          public function send($text, ChannelInterface $channel)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Return type of getUserById() is undeclared type \Slack\User
      Open

          public function getUserById($userId)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method getUsers from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->getUsers()->then(function(array $users) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method send from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->send($text, $channel);
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method apiCall from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->apiCall('chat.postMessage', $parameters);
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of getBotById() is undeclared type \Slack\Bot
      Open

          public function getBotById($botId)
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Checking instanceof against undeclared class \Slack\ChannelInterface
      Open

              if ($channel instanceof ChannelInterface) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method getChannels from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->getChannels()->then(function(array $channels) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Property \Nopolabs\Yabot\Slack\Client->realTimeClient has undeclared type \Slack\RealTimeClient
      Open

          private $realTimeClient;
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Parameter $realTimeClient has undeclared type \Slack\RealTimeClient
      Open

          public function __construct(
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Parameter $log has undeclared type ?\Psr\Log\LoggerInterface
      Open

              array $config = [],
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Return type of reconnect() is undeclared type \React\Promise\PromiseInterface
      Open

          public function reconnect() : PromiseInterface
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Parameter $payload has undeclared type \Slack\Payload
      Open

              $this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Parameter $channel has undeclared type \Slack\ChannelInterface
      Open

          public function post($text, ChannelInterface $channel, array $additionalParameters = [])
      Severity: Minor
      Found in src/Slack/Client.php by phan

      Call to method getBots from undeclared class \Slack\RealTimeClient
      Open

              $this->realTimeClient->getBots()->then(function(array $bots) {
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Call to method connect from undeclared class \Slack\RealTimeClient
      Open

              return $this->realTimeClient->connect();
      Severity: Critical
      Found in src/Slack/Client.php by phan

      Return type of ping() is undeclared type \React\Promise\PromiseInterface
      Open

          public function ping() : PromiseInterface
      Severity: Minor
      Found in src/Slack/Client.php by phan

      The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
      Open

          {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      There must be one blank line after the namespace declaration
      Open

      namespace Nopolabs\Yabot\Slack;
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 space after FUNCTION keyword; 0 found
      Open

              $this->realTimeClient->getBots()->then(function(array $bots) {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 space after FUNCTION keyword; 0 found
      Open

              $this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 space after FUNCTION keyword; 0 found
      Open

              $this->realTimeClient->getUsers()->then(function(array $users) {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 space after FUNCTION keyword; 0 found
      Open

              $this->realTimeClient->getChannels()->then(function(array $channels) {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      The closing parenthesis of a multi-line function declaration must be on a new line
      Open

              LoggerInterface $log = null)
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 space after FUNCTION keyword; 0 found
      Open

              $this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      Expected 1 newline at end of file; 0 found
      Open

      }
      Severity: Minor
      Found in src/Slack/Client.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status