| Conditions | 11 | 
| Paths | 18 | 
| Total Lines | 49 | 
| Code Lines | 28 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 104 | public function scheduleRecalculation(Channel $channel = null)  | 
            ||
| 105 |     { | 
            ||
| 106 |         if ($channel) { | 
            ||
| 107 |             $argument = sprintf('--channel=%s', $channel->getId()); | 
            ||
| 108 | |||
| 109 |             if ($this->isJobRunning($argument)) { | 
            ||
| 110 | return;  | 
            ||
| 111 | }  | 
            ||
| 112 | |||
| 113 | $isActiveChannel = $channel->getStatus() === Channel::STATUS_ACTIVE;  | 
            ||
| 114 | $channelData = $channel->getData();  | 
            ||
| 115 | $rfmEnabled = !empty($channelData[RFMAwareInterface::RFM_STATE_KEY]);  | 
            ||
| 116 | |||
| 117 |             if (!$isActiveChannel || !$rfmEnabled) { | 
            ||
| 118 | return;  | 
            ||
| 119 | }  | 
            ||
| 120 | }  | 
            ||
| 121 | |||
| 122 |         if ($this->getJob()) { | 
            ||
| 123 | return;  | 
            ||
| 124 | }  | 
            ||
| 125 | |||
| 126 | $args = [];  | 
            ||
| 127 |         if ($channel) { | 
            ||
| 128 |             $argument = sprintf('--channel=%s', $channel->getId()); | 
            ||
| 129 | $channelJob = $this->getJob($argument);  | 
            ||
| 130 |             if ($channelJob) { | 
            ||
| 131 | return;  | 
            ||
| 132 | }  | 
            ||
| 133 | |||
| 134 | $args = [$argument];  | 
            ||
| 135 | }  | 
            ||
| 136 | |||
| 137 | $job = new Job(CalculateAnalyticsCommand::COMMAND_NAME, $args);  | 
            ||
| 138 | $em = $this->doctrineHelper->getEntityManager($job);  | 
            ||
| 139 | |||
| 140 |         if (!$channel) { | 
            ||
| 141 |             $channelJobs = $this->getJob('--channel'); | 
            ||
| 142 | |||
| 143 |             if ($channelJobs) { | 
            ||
| 144 |                 foreach ($channelJobs as $channelJob) { | 
            ||
| 145 | $em->remove($channelJob);  | 
            ||
| 146 | }  | 
            ||
| 147 | }  | 
            ||
| 148 | }  | 
            ||
| 149 | |||
| 150 | $em->persist($job);  | 
            ||
| 151 | $em->flush($job);  | 
            ||
| 152 | }  | 
            ||
| 153 | }  | 
            ||
| 154 | 
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.