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', 'portfolio/DefaultPageController'); |
||
| 4 | Loader::load('utility', array( |
||
| 5 | 'Validate')); |
||
| 6 | |||
| 7 | class ContactController extends DefaultPageController |
||
|
0 ignored issues
–
show
|
|||
| 8 | { |
||
| 9 | |||
| 10 | protected function set_data() |
||
| 11 | { |
||
| 12 | $form_results = $this->process_form_data(); |
||
| 13 | |||
| 14 | $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
||
| 15 | $this->set_head('description', "Contact page for Jacob Emerick's Portfolio"); |
||
| 16 | $this->set_head('keywords', 'portfolio, Jacob Emerick, contact, information, request, web development, web programming, print design, freelance'); |
||
| 17 | |||
| 18 | $this->set_body('body_view', 'Contact'); |
||
| 19 | $this->set_body('left_side_data', array( |
||
| 20 | 'title' => "Contact | Jacob Emerick's Portfolio", |
||
| 21 | 'menu' => $this->get_menu(), |
||
| 22 | 'home_link' => Loader::getRootURL())); |
||
| 23 | $this->set_body('body_data', $form_results); |
||
| 24 | |||
| 25 | $this->set_body_view('Page'); |
||
| 26 | } |
||
| 27 | |||
| 28 | View Code Duplication | private function process_form_data() |
|
| 29 | { |
||
| 30 | if(!Request::hasPost()) |
||
| 31 | return array(); |
||
| 32 | |||
| 33 | if(!Validate::checkRequest('post', 'name', 'string')) |
||
| 34 | $error_message['name'] = 'Please enter a value for your name.'; |
||
| 35 | if(!Validate::checkRequest('post', 'email', 'string')) |
||
| 36 | $error_message['email'] = 'Please enter a valid email address.'; |
||
| 37 | if(!Validate::checkRequest('post', 'message', 'string')) |
||
| 38 | $error_message['message'] = 'Please enter a message.'; |
||
| 39 | |||
| 40 | if(!empty($error_message)) |
||
| 41 | { |
||
| 42 | return array( |
||
| 43 | 'error_message' => $error_message, |
||
| 44 | 'value' => Request::getPost()); |
||
| 45 | } |
||
| 46 | |||
| 47 | global $container; |
||
| 48 | $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...
|
|||
| 49 | ->addTo($container['config']->admin_email) |
||
| 50 | ->setSubject('Portfolio Contact') |
||
| 51 | ->setPlainMessage( |
||
| 52 | 'Name: ' . Request::getPost('name') . "\n" . |
||
| 53 | 'Email: ' . Request::getPost('email') . "\n" . |
||
| 54 | 'Message: ' . Request::getPost('message') |
||
| 55 | ) |
||
| 56 | ->send(); |
||
| 57 | |||
| 58 | return array( |
||
| 59 | 'success_message' => "Thank you for your message, ".Request::getPost('name')."! I'll get back to you as soon as possible."); |
||
| 60 | } |
||
| 61 | |||
| 62 | } |
||
| 63 |
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.