Skip to content

Instantly share code, notes, and snippets.

@shadda
Created February 14, 2016 08:04
Show Gist options
  • Save shadda/d3b1407f2bf5b5d35f5e to your computer and use it in GitHub Desktop.
Save shadda/d3b1407f2bf5b5d35f5e to your computer and use it in GitHub Desktop.
<?php
interface IFormHandler
{
public function validate();
}
class FormHandler
{
const METHOD_GET = 2;
const METHOD_POST = 4;
protected $_request = [];
protected $_fields = [];
protected $_optional = [];
protected $_method = self::METHOD_GET;
public function __construct(array $request = [], $method = self::METHOD_GET)
{
$this->_request = $request;
$this->_method = $method;
}
}
class ContactForm extends FormHandler
{
protected $_fields = ['fname', 'lname', 'email', 'salutation', 'title'];
protected $_optional ['salutation', 'title'];
public function validate()
{
//validation as discussed here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment