Showing 38 of 59 total issues
Method make
has 28 arguments (exceeds 4 allowed). Consider refactoring. Open
int $id,
string $type,
?string $title = null,
?string $username = null,
?string $first_name = null,
Function fakeInstance
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
private function fakeInstance(
string $class,
array $additional = [],
bool $fillNullable = true,
array $resolveStack = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function wordWrap
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function wordWrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
{
if ($string === '') {
return '';
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method fakeInstance
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fakeInstance(
string $class,
array $additional = [],
bool $fillNullable = true,
array $resolveStack = []
Method inject
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function inject(Nutgram $bot, MockHandler $mock, HandlerStack $handlerStack): void
{
(function () use ($handlerStack, $mock) {
/** @psalm-scope-this SergiX44\Nutgram\Testing\FakeNutgram */
$this->mockHandler = $mock;
Function parseHeaders
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function parseHeaders(string $headerContent): array
{
$headers = [];
$headerParts = preg_split('/\\R/s', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
foreach ($headerParts as $headerPart) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function addHandlersBy
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function addHandlersBy(
array &$handlers,
string $type,
?string $subType = null,
?string $value = null
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function continueConversation
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function continueConversation(Conversation|callable $conversation): array
{
$resolvedHandlers = [];
if (!$conversation instanceof Conversation || !$conversation->skipHandlers()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method wordWrap
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function wordWrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
{
if ($string === '') {
return '';
}
Function parseRequest
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function parseRequest(): self
{
//get method type
$this->method = $this->request->getMethod();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseRequest
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseRequest(): self
{
//get method type
$this->method = $this->request->getMethod();
Function resolveHandlers
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function resolveHandlers(): array
{
$resolvedHandlers = [];
$updateType = $this->update->getType();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method requestMultipart
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function requestMultipart(
string $endpoint,
?array $multipart = null,
string $mapTo = stdClass::class,
array $options = []
Method handle
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle(): int
{
$bot = app(Nutgram::class);
$refHandlers = new ReflectionProperty(Nutgram::class, "handlers");
Method bootstrap
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function bootstrap(string $token, array $config): void
{
$this->token = $token;
$this->config = $config;
$this->container = new Container();
Method getHandlerName
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getHandlerName(string $signature): ?string
{
$signature = Str::lower($signature);
return match (Str::before($signature, '.')) {
Method make
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
int $id,
bool $is_bot,
string $first_name,
?string $last_name = null,
?string $username = null,
Function addButtonRow
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function addButtonRow(...$buttons): self
{
foreach ($buttons as $button) {
if ($button->callback_data === null || !str_contains($button->callback_data, '@')) {
continue;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method make
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function make(
int $id,
string $type,
?string $title = null,
?string $username = null,
Method resolveHandlers
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function resolveHandlers(): array
{
$resolvedHandlers = [];
$updateType = $this->update->getType();