Showing 27 of 27 total issues
Function word_wrap
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
function word_wrap(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
File MessageListeners.php
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SergiX44\Nutgram\Handlers\Listeners;
use InvalidArgumentException;
Function fakeDataFor
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private function fakeDataFor(
string $class,
array $additional = [],
): array {
$this->resolveStack[] = $class;
- 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
File FakeNutgram.php
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace SergiX44\Nutgram\Testing;
use GuzzleHttp\Handler\MockHandler;
Function addHandlersBy
has a Cognitive Complexity of 17 (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
Method requestMultipart
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function requestMultipart(
string $endpoint,
array $multipart = [],
string $mapTo = stdClass::class,
array $options = []
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 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
Function resolveHandlers
has a Cognitive Complexity of 15 (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
Function requestMultipart
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function requestMultipart(
string $endpoint,
array $multipart = [],
string $mapTo = stdClass::class,
array $options = []
- 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 word_wrap
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function word_wrap(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
{
$this->method = $this->request->getMethod();
$this->headers = $this->request->getHeaders();
- 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
{
$this->method = $this->request->getMethod();
$this->headers = $this->request->getHeaders();
Method bootstrap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function bootstrap(string $token, Configuration $config): void
{
$this->token = $token;
$this->config = $config;
$this->container = new Container();
Method fakeDataFor
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fakeDataFor(
string $class,
array $additional = [],
): array {
$this->resolveStack[] = $class;
Function parseHeaders
has a Cognitive Complexity of 13 (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
Method resolveHandlers
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function resolveHandlers(): array
{
$resolvedHandlers = [];
$updateType = $this->update?->getType();
Method requestJson
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function requestJson(
string $endpoint,
array $json = [],
string $mapTo = stdClass::class,
array $options = []
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 resolveNestedGroups
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function resolveNestedGroups(
array $groups,
array $currentMiddlewares = [],
array $currentScopes = [],
array $currentTags = [],