Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* PHPUnit style mocking:
*/
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
<?php
class ProcessInfo {
/** @var array $processes */
protected $processes = array();
/**
* Find a processes
*
@bgrimes
bgrimes / DiskManager.php
Created November 12, 2012 21:01
Convert scaled bytes to raw bytes
/**
* Convert string such as '500mb' to bytes. Converts KB, MB, GB, TB, PB) The strings
* are case insensitive (mb=MB=m=M, k=K=kb=KB=Kb=kB)
*
* Usage:
* $bytes = convertToBytes("512kb");
*
* @param string $from
*
* @return bool|integer
@bgrimes
bgrimes / curl_get_contents.php
Created June 5, 2012 16:24
Curl get contents
<?php
/**
* Curl get contents instead of file_get_contents.
*
* @param string The URL to grab contents of
* @param array Post data to send to the url, empty if not desired
* @param mixed Bool false if no desired verbose output, string of filename to write to if verbose output desired
* @param mixed False if referer not desired, string if you wish to set a referrer url
* @param mixed False if no cookie desired, string to set the cookie filepath
@bgrimes
bgrimes / colorize.php
Created January 26, 2011 22:27
Provides a function that may be used to style the output of a console application.
<?php
/**
* colorize
* Description: Provides a function that may be used to style the output of a console application.
*
* Examples:
* colorize("Something bolded in cyan on red background", 'bold', 'on_red', 'cyan')
* You may use multiple styles together:
* colorize("Something bolded underlines and blinking.", 'bold', 'underline', 'blink')