Skip to content

Instantly share code, notes, and snippets.

View texdc's full-sized avatar
🕶️

George Cooksey texdc

🕶️
  • Nashville, TN
View GitHub Profile
@texdc
texdc / MailtrapTestCase.php
Last active August 29, 2015 13:56
Mailtrap, Zend Framework 2, and PhpUnit test case
<?php
use InvalidArgumentException;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
/**
* A base testcase for mail transactions with Mailtrap.
*
<?php
namespace Barcode;
use Traversable;
use Barcode\Builder\ObjectBuilderInterface as ObjectBuilder;
use Barcode\Builder\RendererBuilderInterface as RendererBuilder;
use Barcode\Object\SpecificationInterface as ObjectSpecification;
use Barcode\Renderer\SpecificationInterface as RenderSpecification;
<?php
namespace Category\Command;
use Category\CategoryId;
use Message\AbstractMessage;
use Message\Message;
use Message\MessageId;
use Message\MessageTrait;
use Product\Command\ProductsCommandTrait;
@texdc
texdc / Role.php
Last active August 29, 2015 13:56
<?php
namespace My\Role;
use RoleId as BaseId;
class RoleId extends BaseId
{
const ADMIN = 'Admin';
const GUEST = 'Guest';
<?php
namespace My\Composer\Installer;
use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;
use My\Composer\Installer\Exception\InvalidPackageName;
abstract class AbstractInstaller extends LibraryInstaller
{
@texdc
texdc / find_by.php
Last active August 29, 2015 14:11 — forked from mathiasverraes/max.php
<?php
// test data
class Foo
{
private $a;
public function __construct($a)
{
<?php
class A
{
private $a;
public function __construct($a)
{
$this->a = $a;
}
@texdc
texdc / Value.php
Last active August 29, 2015 14:13
<?php
/**
* Allows value objects to expose their properties while maintaining immutability.
*
* Inject your properties in your constructor.
* Define your properties in the docblock for your class with {@code @property}.
* Mutability is just a bug waiting to happen.
*/
abstract class Value
@texdc
texdc / FilterType.js
Last active August 29, 2015 14:21
Type-Safe Enum in Javascript
var FilterType = (function() {
'use strict';
var _type = function(type) {
Object.defineProperties(this, {
toString: { value: function() {
return type;
}},
eq: { value: function(another) {
return type === another.toString();
@texdc
texdc / 1-Notes.md
Last active December 19, 2015 08:59
Notes on refactoring ZF2's "InputFilter"

A few notes from my personal gripes about what InputFilter is and does.

  1. InputFilter is a terrible name as the class mixes sanitation and validation. Rename to something far more appropriate (e.g. InputManager?).
  2. Data should only be processed, not stored - remove setData()

SoC Article

For example, if both raw and sanitized data are required: