| Conditions | 10 |
| Paths | 37 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 95 | public function onBeforeWrite() |
||
| 96 | { |
||
| 97 | parent::onBeforeWrite(); |
||
| 98 | |||
| 99 | if ($this->owner->FirstExecution) { |
||
| 100 | $changed = $this->owner->getChangedFields(); |
||
| 101 | $changed = ( |
||
| 102 | isset($changed['FirstExecution']) |
||
| 103 | || isset($changed['ExecuteInterval']) |
||
| 104 | || isset($changed['ExecuteEvery']) |
||
| 105 | || isset($changed['ExecuteFree']) |
||
| 106 | ); |
||
| 107 | |||
| 108 | if ($changed && $this->owner->ScheduledJobID) { |
||
| 109 | if ($this->owner->ScheduledJob()->exists()) { |
||
| 110 | $this->owner->ScheduledJob()->delete(); |
||
| 111 | } |
||
| 112 | |||
| 113 | $this->owner->ScheduledJobID = 0; |
||
| 114 | } |
||
| 115 | |||
| 116 | if (!$this->owner->ScheduledJobID) { |
||
| 117 | $job = new ScheduledExecutionJob($this->owner); |
||
| 118 | $time = date('Y-m-d H:i:s'); |
||
| 119 | if ($this->owner->FirstExecution) { |
||
| 120 | $time = date('Y-m-d H:i:s', strtotime($this->owner->FirstExecution)); |
||
| 121 | } |
||
| 122 | |||
| 123 | $this->owner->ScheduledJobID = singleton('Symbiote\\QueuedJobs\\Services\\QueuedJobService') |
||
| 124 | ->queueJob($job, $time); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 137 |
This check marks private properties in classes that are never used. Those properties can be removed.