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 / 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 / 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
<?php
class A
{
private $a;
public function __construct($a)
{
$this->a = $a;
}
@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)
{
@texdc
texdc / autoload.php
Last active February 16, 2016 16:07
build_autoloader()
<?php
namespace texdc\autoload;
use InvalidArgumentException;
/**
* @param array $aDirectoryMap
* @return callable
*/
<?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 / 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 Category\Command;
use Category\CategoryId;
use Message\AbstractMessage;
use Message\Message;
use Message\MessageId;
use Message\MessageTrait;
use Product\Command\ProductsCommandTrait;
<?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;
@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.
*