Showing 1,189 of 1,190 total issues
Function getInvalid
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getInvalid(): array
{
$invalid = [];
if (!$this->hasValidEmail()) {
- 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 address
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function address(Request $request, string $phoneNumber): JsonResponse
{
$db = app(DbService::class);
$db->addLoadedTable('fakturas', 'email', 'post');
Contact
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class Contact extends AbstractEntity
{
/** Table name in database. */
public const TABLE_NAME = 'email';
The class ExplorerController has 20 public methods. Consider refactoring ExplorerController to keep number of public methods under 10. Open
class ExplorerController extends AbstractAdminController
{
private FileService $fileService;
public function __construct()
- 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
The class InvoiceService has an overall complexity of 94 which is very high. The configured complexity threshold is 50. Open
class InvoiceService
{
/**
* Create an invoice from the client cart array.
*
- Exclude checks
The class Category has an overall complexity of 62 which is very high. The configured complexity threshold is 50. Open
class Category extends AbstractRenderable
{
use HasIcon;
/** Table name in database. */
- Exclude checks
The class MaintenanceController has 12 public methods. Consider refactoring MaintenanceController to keep number of public methods under 10. Open
class MaintenanceController extends AbstractAdminController
{
/**
* Create or edit category.
*
- 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
The class ExportController has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class ExportController extends AbstractAdminController
{
/** @var array<int, string> */
private array $header = [
'ID',
- Exclude checks
The class Page has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class Page extends AbstractRenderable implements InterfaceRichText
{
use HasIcon;
/** Table name in database. */
- Exclude checks
The class Payment has an overall complexity of 61 which is very high. The configured complexity threshold is 50. Open
class Payment extends Base
{
private InvoiceService $invoiceService;
/**
- Exclude checks
The class InvoiceController has an overall complexity of 55 which is very high. The configured complexity threshold is 50. Open
class InvoiceController extends AbstractAdminController
{
/**
* List of invoices.
*
- Exclude checks
The class Invoice has an overall complexity of 138 which is very high. The configured complexity threshold is 50. Open
class Invoice extends AbstractEntity
{
/** Table name in database. */
public const TABLE_NAME = 'fakturas';
- Exclude checks
The class InvoiceController has 11 public methods. Consider refactoring InvoiceController to keep number of public methods under 10. Open
class InvoiceController extends AbstractAdminController
{
/**
* List of invoices.
*
- 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
The class ExplorerController has an overall complexity of 127 which is very high. The configured complexity threshold is 50. Open
class ExplorerController extends AbstractAdminController
{
private FileService $fileService;
public function __construct()
- Exclude checks
Method createFromCart
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createFromCart(array $cart): Invoice
{
$db = app(DbService::class);
$orm = app(OrmService::class);
$amount = 0;
Method getPageData
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getPageData(string $type, Page $page): array
{
$categories = $page->getCategories();
$paths = [];
$isVisible = false;
Function getTransactionData
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
private function getTransactionData(string $orderId): stdClass
{
foreach (['PAYMENT_CAPTURED', 'PAYMENT_NEW', 'PAYMENT_DELETED'] as $status) {
$response = $this->getConnection()->gettransactionlist($this->getSearchData($orderId, $status));
if ($response instanceof stdClass) {
- 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
Category
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Category extends AbstractRenderable
{
use HasIcon;
/** Table name in database. */
File InvoiceController.php
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Http\Controllers\Admin;
use App\Countries;
ExplorerController
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class ExplorerController extends AbstractAdminController
{
private FileService $fileService;
public function __construct()