File TriggerCampaignController.php
has 463 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle\Controller;
use Doctrine\ORM\EntityNotFoundException;
TriggerCampaignController
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class TriggerCampaignController extends AbstractFormController
{
public const PERMISSIONS = [
'create' => 'printmailing:campaigns:create',
'delete' => 'printmailing:campaigns:delete',
Method createTriggerCampaignModifyRequest
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
Method newAction
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function newAction()
{
$this->setSession();
if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
Function newAction
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function newAction()
{
$this->setSession();
if (!$this->get('mautic.security')->isGranted(self::PERMISSIONS['create'])) {
- 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 indexAction
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexAction($page = 1)
{
//set some permissions
$permissions = $this->getPermissions();
if (!$permissions[self::PERMISSIONS['view']]) {
Function createTriggerCampaignModifyRequest
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function createTriggerCampaignModifyRequest(TriggerCampaign $triggerCampaign, array $postActionVars, $action, $ignorePost)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
- 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 deleteMultipleCampaigns
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function deleteMultipleCampaigns($postActionVars, &$flashes)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
$triggerCampaignIds = json_decode($this->request->query->get('ids', '{}'));
Method editAction
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function editAction($objectId, $ignorePost = false, $clone = false)
{
$this->setSession();
$postActionVars = $this->getPostActionVars();
Method deleteAction
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteAction($objectId, $batch = false)
{
$this->setSession();
$page = $this->session->get(self::SESSION_VARS['page'], 1);
$viewParameters = ['page' => $page];
Method getTriggerCampaigns
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function getTriggerCampaigns($filter, $start, $limit, $orderBy, $orderByDir)
Function deleteAction
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function deleteAction($objectId, $batch = false)
{
$this->setSession();
$page = $this->session->get(self::SESSION_VARS['page'], 1);
$viewParameters = ['page' => $page];
- 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 deleteMultipleCampaigns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function deleteMultipleCampaigns($postActionVars, &$flashes)
{
/** @var TriggerCampaignModel $triggerCampaignModel */
$triggerCampaignModel = $this->getModel(TriggerCampaignModel::NAME);
$triggerCampaignIds = json_decode($this->request->query->get('ids', '{}'));
- 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
Avoid too many return
statements within this method. Open
return $this->delegateView([
'viewParameters' => [
'form' => $this->setFormTheme($form, self::TEMPLATES['form'], self::THEMES['variables']),
'currentListId' => $triggerCampaign->getId(),
],