Skip to content

Instantly share code, notes, and snippets.

@ironsmile
Created February 7, 2012 14:23
Show Gist options
  • Save ironsmile/1759915 to your computer and use it in GitHub Desktop.
Save ironsmile/1759915 to your computer and use it in GitHub Desktop.
distrustful function
<?php
// freakishly distrustful about its arguments function
function document_mark_as_sent($invoices){
global $page, $db;
if(empty($invoices)){ return; }
if(!is_array($invoices)){ $invoices = array((int)$invoices); }
if(!is_object($page) or !is_object($db)){ return; }
if(!isset($page->firm) or !$page->firm){ return; }
if( is_object($invoices[0]) ){ // значи е масив от Invoice обекти
$invoices = array_map(create_function('$i', 'return $i->id;'), $invoices);
}
... тяло на фунцкията ...
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment