Skip to content

Instantly share code, notes, and snippets.

View dharkness's full-sized avatar

David Harkness dharkness

  • Anywhere Real Estate
  • Portland, Oregon
View GitHub Profile
public function runBare() {
self::checkForCatastrophicError();
self::checkForSkipAllTests();
$this->setBaseUp();
try {
parent::runBare();
}
catch (Exception $e) {
// rethrown below
}
@dharkness
dharkness / foreach-vs-array_map.php
Created September 26, 2012 01:55
Benchmark: foreach vs. array_map
<?php
function benchmark($label, $callback) {
$start = microtime(true);
$callback();
$time = microtime(true) - $start;
echo "Run $label took " . number_format(1000 * $time, 3) . " ms\n";
}
@dharkness
dharkness / Hamcrest_Integration_PHPUnit_TestCase.php
Created October 27, 2012 19:55
Using Hamcrest matchers with PHPUnit
<?php
class Hamcrest_Integration_PHPUnit_TestCase extends PHPUnit_Framework_TestCase
{
/**
* Collects assertions performed by Hamcrest matchers during the test.
*/
public function runBare() {
Hamcrest_MatcherAssert::resetCount();
try {
@dharkness
dharkness / CompileViewsCommand.php
Created September 13, 2018 23:49
Laravel command to compile all views
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Blade;
use Symfony\Component\Finder\Finder;
use Throwable;
/**