Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Vehikl\Feature\Tests;
use PHPUnit\Framework\TestCase;
class FeatureToggleTest extends TestCase
{
public function test_it_executes_the_on_method_when_the_feature_is_on()
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
<?php
Collection::macro('diffRecursive', function ($comparate) {
return $this->map(function ($item, $key) use ($comparate) {
$comparate = $this->getArrayableItems($comparate);
if (! isset($comparate[$key])) {
return $item;
}
if (Arr::accessible($item)) {
$item = $this->getArrayableItems($item);
@bbrothers
bbrothers / MimeTypeException.php
Created April 13, 2016 15:12
Should Exceptions handler their own assertion logic?
<?php
class MimeTypeException extends Exception
{
const SUPPORTED_MIME_TYPES = ['image/gif', 'image/jpeg', 'impage/png'];
public static function isOfSupportedMimeType($mimeType)
{
if (!in_array($mimeType, SUPPORTED_MIME_TYPES)) {
throw new static(
@bbrothers
bbrothers / reminder
Created February 24, 2016 19:12
Virtual Box: make the client use the host computer as a proxy for resolving hosts
VBoxManage modifyvm "VM name" --natdnshostresolver1 on
@bbrothers
bbrothers / devldn.raml
Created November 25, 2015 07:59
First rough draft of the devldn API
#%RAML 0.8
title: devldn
version: v1
baseUri: https://devldn.dev
mediaType: application/json
resourceTypes:
- readOnlyCollection:
description: Collection of available <<resourcePathName>>.
get:
#!/bin/bash
git diff --cached --name-only | while read FILE; do
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then
# Courtesy of swytsh from the comments below.
if [[ -f $FILE ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo -e "\e[1;31m\tAborting commit due to files with syntax errors" >&2
exit 1
@bbrothers
bbrothers / DecoratorTrait.php
Created September 15, 2015 17:59
Array/Object Unifier
<?php namespace Acme\Util;
use ArrayAccess;
use Countable;
trait DecoratorTrait
{
/**
* The object or array being decorated
*
<?php
use ArrayObject;
use OutOfBoundsException;
use SplObjectStorage;
class IdentityMap
{
/**
* @var ArrayObject
@bbrothers
bbrothers / showlayout.css
Created March 23, 2014 01:39
Highlight DOM elements
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }