Skip to content

Instantly share code, notes, and snippets.

View GRAgmLauncher's full-sized avatar

Jon LeMaitre GRAgmLauncher

View GitHub Profile
@GRAgmLauncher
GRAgmLauncher / wtf.php
Last active August 29, 2015 14:27
Refactor
echo 'test';
@GRAgmLauncher
GRAgmLauncher / FooContext.php
Created April 15, 2015 08:12
Tight coupling
interface FooContext {
public function foo(); // i.e. cache
public function bar(); // i.e. dbConnection
public function baz(); // i.e. logger
}
// If we're not doing dependency injection, then you need to handle permutations like below...
// It's easy to see how quickly this gets out of control
@GRAgmLauncher
GRAgmLauncher / APIRequest.php
Last active August 29, 2015 14:19
API request validator concept
<?php
class APIRequest extends FormRequest
{
public function response(array $errors)
{
if ($this->ajax() || $this->wantsJson())
{
return new JsonResponse($errors, $this->responseCode());
}