| Conditions | 8 | 
| Paths | 26 | 
| Total Lines | 66 | 
| Code Lines | 44 | 
| 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  | 
            ||
| 116 | protected function sendEmail($reminder, $recordOrEmail, $isTestOnly, $force = false)  | 
            ||
| 117 |     { | 
            ||
| 118 | $filter = array(  | 
            ||
| 119 | 'EmailReminder_NotificationScheduleID' => $reminder->ID,  | 
            ||
| 120 | );  | 
            ||
| 121 |         if ($recordOrEmail instanceof DataObject) { | 
            ||
| 122 | $email_field = $reminder->EmailField;  | 
            ||
| 123 | $email = $recordOrEmail->$email_field;  | 
            ||
| 124 | $record = $recordOrEmail;  | 
            ||
| 125 | $filter['ExternalRecordClassName'] = $recordOrEmail->ClassName;  | 
            ||
| 126 | $filter['ExternalRecordID'] = $recordOrEmail->ID;  | 
            ||
| 127 |         } else { | 
            ||
| 128 | $email = strtolower(trim($recordOrEmail));  | 
            ||
| 129 | $record = Injector::inst()->get($reminder->DataObject);  | 
            ||
| 130 | }  | 
            ||
| 131 | $filter['EmailTo'] = $email;  | 
            ||
| 132 |         if (Email::validEmailAddress($email)) { | 
            ||
| 133 | $send = true;  | 
            ||
| 134 |             if(! $force){ | 
            ||
| 135 | $logs = EmailReminder_EmailRecord::get()->filter($filter);  | 
            ||
| 136 | $send = true;  | 
            ||
| 137 |                 foreach ($logs as $log) { | 
            ||
| 138 |                     if (! $log->canSendAgain()) { | 
            ||
| 139 | $send = false;  | 
            ||
| 140 | break;  | 
            ||
| 141 | }  | 
            ||
| 142 | }  | 
            ||
| 143 | }  | 
            ||
| 144 |             if ($send) { | 
            ||
| 145 | $log = EmailReminder_EmailRecord::create($filter);  | 
            ||
| 146 | |||
| 147 | $subject = $reminder->EmailSubject;  | 
            ||
| 148 | $email_content = $reminder->Content;  | 
            ||
| 149 |                 if ($replacerObject = $this->getReplacerObject()) { | 
            ||
| 150 | $email_content = $replacerObject->replace($reminder, $record, $email_content);  | 
            ||
| 151 | $subject = $replacerObject->replace($reminder, $record, $subject);  | 
            ||
| 152 | }  | 
            ||
| 153 | $email_content = $this->getParsedContent($record, $email_content);  | 
            ||
| 154 | |||
| 155 | /* Parse HTML like a template, and translate any internal links */  | 
            ||
| 156 | $data = ArrayData::create(array(  | 
            ||
| 157 | 'Content' => $email_content  | 
            ||
| 158 | ));  | 
            ||
| 159 | |||
| 160 | // $email_body = $record->renderWith(SSViewer::fromString($reminder->Content));  | 
            ||
| 161 |                 // echo $record->renderWith('Email_Reminder_Standard_Template');//$email_body; | 
            ||
| 162 | $email = new Email(  | 
            ||
| 163 | $reminder->EmailFrom,  | 
            ||
| 164 | $email,  | 
            ||
| 165 | $subject  | 
            ||
| 166 | );  | 
            ||
| 167 | |||
| 168 |                 $email->setTemplate('Email_Reminder_Standard_Template'); | 
            ||
| 169 | |||
| 170 | $email->populateTemplate($data);  | 
            ||
| 171 | |||
| 172 | // $email->send();  | 
            ||
| 173 | $log->IsTestOnly = $isTestOnly;  | 
            ||
| 174 | $log->Result = $email->send();  | 
            ||
| 175 | $log->EmailReminder_NotificationScheduleID = $reminder->ID;  | 
            ||
| 176 | $log->EmailContent = $email->body;  | 
            ||
| 177 | $log->write();  | 
            ||
| 178 | }  | 
            ||
| 179 | }  | 
            ||
| 180 | return false;  | 
            ||
| 181 | }  | 
            ||
| 182 | |||
| 216 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.