Skip to content

Instantly share code, notes, and snippets.

@skollro
skollro / join.php
Last active April 29, 2017 21:06
A join collection macro
<?php
Collection::macro('join', function ($items, callable $callback) {
return $this->flatMap(function ($value) use ($items, $callback) {
return $items->filter(function ($item) use ($value, $callback) {
return $callback($value, $item);
})->map(function ($item) use ($value) {
return new Collection([$value, $item]);
});
});
<?php
class Match
{
protected $value;
protected $result;
protected $hasMatch;
public function __construct($value)
{
<?php
class FakeSoapClient extends \SoapClient
{
protected $response;
protected $customizer;
public static function wsdl($wsdl)
{
return new self($wsdl);
<?php
class Temporary
{
public static function file($contents, $callback)
{
$path = tempnam(sys_get_temp_dir(), 'php_');
file_put_contents($path, $contents);
try {