Skip to content

Instantly share code, notes, and snippets.

@daviddeutsch
Last active December 20, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddeutsch/6147078 to your computer and use it in GitHub Desktop.
Save daviddeutsch/6147078 to your computer and use it in GitHub Desktop.
Cleanup Ex 1
<?php
// Original function
public function find($type, $sql = null, $bindings = array()) {
if ($sql instanceof RedBean_SQLHelper) list($sql, $bindings) = $sql->getQuery();
if (!is_array($bindings)) throw new RedBean_Exception_Security('Expected array, ' . gettype($bindings) . ' given.');
return $this->redbean->find($type, array(), $sql, $bindings);
}
// Split open Ifs, add whitespace, newlines
public function find( $type, $sql = null, $bindings = array() )
{
if ( $sql instanceof RedBean_SQLHelper ) {
list($sql, $bindings) = $sql->getQuery();
}
if ( !is_array($bindings) ) {
throw new RedBean_Exception_Security('Expected array, ' . gettype($bindings) . ' given.');
}
return $this->redbean->find($type, array(), $sql, $bindings);
}
// 80 char limit
public function find( $type, $sql = null, $bindings = array() )
{
if ( $sql instanceof RedBean_SQLHelper ) {
list($sql, $bindings) = $sql->getQuery();
}
if ( !is_array($bindings) ) {
throw new RedBean_Exception_Security(
'Expected array, ' . gettype($bindings) . ' given.'
);
}
return $this->redbean->find($type, array(), $sql, $bindings);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment