This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dispatcher = new EventDispatcher; | |
class SendWelcomeEmail implements QueuedEventHandler { | |
public function when(Event $event) { | |
// delegate to whenUserHasRegistered, whenFoo.. | |
} | |
private function whenUserHasRegistered(UserHasRegistered $event) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__ . 'path/to/src/Verraes/Lambdalicious/load.php'; | |
assert( | |
isatom(@my_atom) | |
); | |
atom(@my_atom); | |
assert( | |
isatom(my_atom) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filtering a array by its keys using a callback. | |
* | |
* @param $array array The array to filter | |
* @param $callback Callback The filter callback, that will get the key as first argument. | |
* | |
* @return array The remaining key => value combinations from $array. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Will handle downloads for $_REQUEST['file'] | |
* @author Julius Beckmann | |
*/ | |
function handleForcedDownloads($parameterName='file', $exit=true) | |
{ | |
if(isset($_REQUEST[$parameterName])) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Creating MongoDB like ObjectIDs. | |
* Using current timestamp, hostname, processId and a incremting id. | |
* | |
* @author Julius Beckmann | |
*/ | |
function createMongoDbLikeId($timestamp, $hostname, $processId, $id) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class Basket implements RecordsEvents | |
{ | |
private $basketCanOnlyContainFiveProducts; | |
private function __construct() | |
{ | |
$this->basketCanOnlyContainFiveProducts = new BasketCanOnlyContainFiveProducts(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$addOne = partial(operator('+'), 1); | |
$double = partial(operator('*'), 2); | |
$greaterThan3 = partial(operator('>'), …(), 3); | |
assert( | |
map([1, 2, 3], $double)->§ | |
== [2, 4, 6] | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\Role; | |
use RoleId as BaseId; | |
class RoleId extends BaseId | |
{ | |
const ADMIN = 'Admin'; | |
const GUEST = 'Guest'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Category\Command; | |
use Category\CategoryId; | |
use Message\AbstractMessage; | |
use Message\Message; | |
use Message\MessageId; | |
use Message\MessageTrait; | |
use Product\Command\ProductsCommandTrait; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom error handler | |
* | |
* @see http://www.php.net/manual/en/class.errorexception.php#95415 | |
*/ | |
set_error_handler(function ($number, $string, $file, $line) { | |
// Determine if this error is enabled (php.ini, .htaccess, etc) | |
if (!(error_reporting() & $number)) { |
OlderNewer