jacobemerick /
web
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <? |
||
| 2 | |||
| 3 | Loader::load('controller', 'site/DefaultPageController'); |
||
| 4 | Loader::load('utility', array( |
||
| 5 | 'Mail', |
||
| 6 | 'Validate')); |
||
| 7 | |||
| 8 | final class ContactController extends DefaultPageController |
||
|
0 ignored issues
–
show
|
|||
| 9 | { |
||
| 10 | |||
| 11 | protected function set_head_data() |
||
| 12 | { |
||
| 13 | $this->set_title("Contact Form for Jacob Emerick's Sites"); |
||
| 14 | $this->set_description("Want to reach out to Jacob Emerick with questions or concerns? Well, then here's a handy contact form for you that will connect you with the man himself."); |
||
| 15 | $this->set_keywords(array('contact', 'webmaster', 'support', 'help', 'Jacob Emerick')); |
||
| 16 | |||
| 17 | parent::set_head_data(); |
||
| 18 | } |
||
| 19 | |||
| 20 | protected function set_body_data() |
||
| 21 | { |
||
| 22 | parent::set_body_data(); |
||
| 23 | |||
| 24 | $this->set_body('top_data', array('title' => 'Contact Me')); |
||
| 25 | |||
| 26 | $this->set_body('body_data', $this->get_form_results()); |
||
| 27 | $this->set_body('body_view', 'Contact'); |
||
| 28 | } |
||
| 29 | |||
| 30 | View Code Duplication | private function get_form_results() |
|
| 31 | { |
||
| 32 | if(!Request::hasPost()) |
||
| 33 | return array(); |
||
| 34 | |||
| 35 | if(!Validate::checkRequest('post', 'name', 'string')) |
||
| 36 | $error_message['name'] = 'Please enter a value for your name.'; |
||
| 37 | if(!Validate::checkRequest('post', 'email', 'string')) |
||
| 38 | $error_message['email'] = 'Please enter a valid email address.'; |
||
| 39 | if(!Validate::checkRequest('post', 'message', 'string')) |
||
| 40 | $error_message['message'] = 'Please enter a message.'; |
||
| 41 | |||
| 42 | if(!empty($error_message)) |
||
| 43 | { |
||
| 44 | return array( |
||
| 45 | 'error_message' => $error_message, |
||
| 46 | 'value' => Request::getPost()); |
||
| 47 | } |
||
| 48 | |||
| 49 | global $container; |
||
| 50 | $sent = $container['mail'] |
||
|
0 ignored issues
–
show
$sent is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the Loading history...
|
|||
| 51 | ->addTo($container['config']->admin_email) |
||
| 52 | ->setSubject('Site Contact') |
||
| 53 | ->setPlainMessage( |
||
| 54 | 'Name: ' . Request::getPost('name') . "\n" . |
||
| 55 | 'Email: ' . Request::getPost('email') . "\n" . |
||
| 56 | 'Message: ' . Request::getPost('message') |
||
| 57 | ) |
||
| 58 | ->send(); |
||
| 59 | |||
| 60 | return array( |
||
| 61 | 'success_message' => "Thank you for your message, " . Request::getPost('name') . "! I'll get back to you as soon as possible."); |
||
| 62 | } |
||
| 63 | |||
| 64 | } |
||
| 65 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.