Skip to content

Instantly share code, notes, and snippets.

View andho's full-sized avatar

Amjad Mohamed andho

View GitHub Profile
@andho
andho / invoice.php
Created January 11, 2012 07:38
Normal Doctrinized Invoice
<?php
class Invoice {
private $_items;
private $_totalAmount = 0;
private $_sentDate;
public function isSent() {
return !is_null($this->_sentDate);
}
@andho
andho / check_fields_using_array.php
Created January 7, 2011 15:09
Demonstrating check for required fields with use of an array
public function __construct($data) {
$address = array('name', 'post_code');
$business = array('name', 'address', 'post_code', 'intro');
if ($data['type] == 'business') $fields = $business;
else $fields = $address;
if (count(array_intersect($fields, array_keys($data))) != count($fields)) {
throw new Exception("Required data was not supplied to the Address object");
}