src/Slack/Client.php
Client
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Client
{
use ConfigTrait;
use LogTrait;
The class Client has 15 public methods. Consider refactoring Client to keep number of public methods under 10. Open
Open
class Client
{
use ConfigTrait;
use LogTrait;
- Read upRead up
- Exclude checks
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
Open
RealTimeClient $realTimeClient,
Users $users,
Bots $bots,
Channels $channels,
array $config = [],
The class Client has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. Wontfix
Wontfix
class Client
{
use ConfigTrait;
use LogTrait;
- Read upRead up
- Exclude checks
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
Open
return $this->getRealTimeClient()->ping();
- Exclude checks
Call to method getUsername
from undeclared class \Slack\User
Open
Open
return $this->authedUser->getUsername();
- Exclude checks
Return type of getUserByName()
is undeclared type \Slack\User
Open
Open
public function getUserByName($name)
- Exclude checks
Parameter $user
has undeclared type \Slack\User
Open
Open
$this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
- Exclude checks
Call to method apiCall
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->apiCall('chat.postMessage', $parameters);
- Exclude checks
Return type of getChannelById()
is undeclared type \Slack\Channel
Open
Open
public function getChannelById($channelId)
- Exclude checks
Return type of getChannelByName()
is undeclared type \Slack\Channel
Open
Open
public function getChannelByName($name)
- Exclude checks
Call to method getAuthedUser
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
- Exclude checks
Property \Nopolabs\Yabot\Slack\Client->authedUser
has undeclared type \Slack\User
Open
Open
protected $authedUser;
- Exclude checks
Call to method on
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
- Exclude checks
Checking instanceof against undeclared class \Slack\ChannelInterface
Open
Open
if ($channel instanceof ChannelInterface) {
- Exclude checks
Call to method disconnect
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->disconnect();
- Exclude checks
Call to method getId
from undeclared class \Slack\ChannelInterface
Open
Open
'channel' => $channel->getId(),
- Exclude checks
Return type of getBotByName()
is undeclared type \Slack\Bot
Open
Open
public function getBotByName($name)
- Exclude checks
Call to method connect
from undeclared class \Slack\RealTimeClient
Open
Open
return $this->realTimeClient->connect();
- Exclude checks
Checking instanceof against undeclared class \Slack\ChannelInterface
Open
Open
if ($channel instanceof ChannelInterface) {
- Exclude checks
Return type of connect()
is undeclared type \React\Promise\PromiseInterface
Open
Open
public function connect() : PromiseInterface
- Exclude checks
Call to method disconnect
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->disconnect();
- Exclude checks
Parameter $channel
has undeclared type \Slack\ChannelInterface
Open
Open
public function send($text, ChannelInterface $channel)
- Exclude checks
Return type of getUserById()
is undeclared type \Slack\User
Open
Open
public function getUserById($userId)
- Exclude checks
Call to method getUsers
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->getUsers()->then(function(array $users) {
- Exclude checks
Call to method send
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->send($text, $channel);
- Exclude checks
Call to method apiCall
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->apiCall('chat.postMessage', $parameters);
- Exclude checks
Return type of getBotById()
is undeclared type \Slack\Bot
Open
Open
public function getBotById($botId)
- Exclude checks
Checking instanceof against undeclared class \Slack\ChannelInterface
Open
Open
if ($channel instanceof ChannelInterface) {
- Exclude checks
Call to method getChannels
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->getChannels()->then(function(array $channels) {
- Exclude checks
Property \Nopolabs\Yabot\Slack\Client->realTimeClient
has undeclared type \Slack\RealTimeClient
Open
Open
private $realTimeClient;
- Exclude checks
Parameter $realTimeClient
has undeclared type \Slack\RealTimeClient
Open
Open
public function __construct(
- Exclude checks
Parameter $log
has undeclared type ?\Psr\Log\LoggerInterface
Open
Open
array $config = [],
- Exclude checks
Return type of reconnect()
is undeclared type \React\Promise\PromiseInterface
Open
Open
public function reconnect() : PromiseInterface
- Exclude checks
Parameter $payload
has undeclared type \Slack\Payload
Open
Open
$this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
- Exclude checks
Parameter $channel
has undeclared type \Slack\ChannelInterface
Open
Open
public function post($text, ChannelInterface $channel, array $additionalParameters = [])
- Exclude checks
Call to method getBots
from undeclared class \Slack\RealTimeClient
Open
Open
$this->realTimeClient->getBots()->then(function(array $bots) {
- Exclude checks
Call to method connect
from undeclared class \Slack\RealTimeClient
Open
Open
return $this->realTimeClient->connect();
- Exclude checks
Return type of ping()
is undeclared type \React\Promise\PromiseInterface
Open
Open
public function ping() : PromiseInterface
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
Open
{
- Exclude checks
There must be one blank line after the namespace declaration Open
Open
namespace Nopolabs\Yabot\Slack;
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$this->realTimeClient->getBots()->then(function(array $bots) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$this->realTimeClient->getAuthedUser()->then(function(User $user) use ($authedUserUpdated) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$this->realTimeClient->getUsers()->then(function(array $users) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$this->realTimeClient->getChannels()->then(function(array $channels) {
- Exclude checks
The closing parenthesis of a multi-line function declaration must be on a new line Open
Open
LoggerInterface $log = null)
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$this->realTimeClient->on($event, function(Payload $payload) use ($onEvent) {
- Exclude checks
Expected 1 newline at end of file; 0 found Open
Open
}
- Exclude checks