Skip to content

Instantly share code, notes, and snippets.

<?php
class number
{
private $value = 0;
public function addNumber(number $number)
{
return $number->add($this->value);
}
@mageekguy
mageekguy / gist:c002ec07dfc6cd176fe2
Last active August 29, 2015 14:01
A grummfy factory
<?php
namespace grummfy;
interface worker
{
function execute();
}
interface job
<?php
namespace jobs\script\configuration\cli;
use
jobs\world
;
class parser
{
<?php
require __DIR__ . '/vendor/autoload.php';
use estvoyage\statsd;
$connection = new statsd\connection\internet(new statsd\address);
(new statsd\packet)
->adds([ new statsd\metric\timing('speed1', 1), new statsd\metric\gauge('gauge1', 5), new statsd\metric\timing('speed2', 3) ])
function add(statsd\metric $metric, callable $callback)
{
$packet = clone $this;
$callback($packet->addMetric($metric));
return $this;
}
function adds(array $metrics, callable $callback)
private static function isVariadic(\reflectionParameter $parameter)
{
return (method_exists($parameter, 'isVariadic') && $parameter->isVariadic());
}
protected function getParametersSignature(\reflectionMethod $method, $forceMockController = false)
{
$parameters = array();
$mustBeNull = $this->isOrphanized($method->getName());
foreach ($method->getParameters() as $parameter)
{
$parameterCode = self::getParameterType($parameter) . ($parameter->isPassedByReference() == false ? (self::isVariadic($parameter) === false ? '' : '...' ) : '& ') . '$' . $parameter->getName();
@mageekguy
mageekguy / gist:91912fccd7aaaae4141d
Last active August 29, 2015 14:13
East oriented account transfert
<?php
namespace east;
class amount
{
private
$value
;
@mageekguy
mageekguy / gist:03fe32a94fd679e7f55d
Last active August 29, 2015 14:13
East oriented body
<?php
final class celsius
{
private
$value
;
function __construct($value)
{
@mageekguy
mageekguy / gist:101480a32660c4860bb6
Created January 13, 2015 14:02
ArrayAccess and "undefined" key
<?php
class foo implements arrayAccess
{
public $values;
function offsetSet($key, $value)
{
var_dump($key);