$upper = pipe('strtoupper');
$rev = $upper->pipe('strrev');
echo $upper('hello');
echo $rev('Hello');
echo pipe('strtoupper', 'strrev')('hello');
This file contains hidden or 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 | |
return [ | |
[ | |
'title' => 'Nubank', | |
'amount' => 1455.73, | |
'due_date' => new \DateTime('01-11-2016'), | |
'tags' => [], | |
'paid' => true, | |
], |
This file contains hidden or 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 | |
declare(strict_types = 1); | |
function partial(callable $fn, ...$args) | |
{ | |
$arity = (new \ReflectionFunction($fn))->getNumberOfRequiredParameters(); | |
return isset($args[$arity - 1]) | |
? $fn(...$args) |
This file contains hidden or 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 | |
declare(strict_types = 1); | |
function partial(callable $fn, ...$args) | |
{ | |
$numReqParams = (new \ReflectionFunction($fn))->getNumberOfRequiredParameters(); | |
return isset($args[$numReqParams - 1]) | |
? $fn(...$args) |
This file contains hidden or 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 | |
function qsort(array $xs) | |
{ | |
$xs = array_values($xs); | |
if (false === array_key_exists(1, $xs)) { | |
return $xs; | |
} | |
This file contains hidden or 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 Sergiors\Sergiors\Silex\Provider; | |
use Silex\Application; | |
use Silex\ServiceProviderInterface; | |
use Mailgun\Mailgun; | |
//use Pimple/Container; | |
//use Pimple/ServiceProviderInterface; |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# from sig import Provider | |
class Container(dict): | |
def __delitem__(self, name): | |
if self.has(name): | |
dict.__delitem__(self, name) |
This file contains hidden or 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 | |
foreach ($classMetadata->getEmbeddedClasses() as $embeddedMetadata) { | |
if ($embeddedMetadata->isInherited()) { | |
continue; | |
} | |
$event->getClassMetadata()->mapField([ | |
'fieldName' => $embeddedMetadata->getPropertyName(), | |
'columnName' => $embeddedMetadata->getColumnAttribute()->name, |
This file contains hidden or 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 | |
function every($fn, $ls) | |
{ | |
$keys = array_keys($ls); | |
$params = (new \ReflectionFunction($fn))->getParameters(); | |
return array_reduce($keys, function ($carry, $idx) use ($fn, $ls, $params) { | |
$args = $ls[$idx]; |
dog = new Dog()
// ...
// Não importa se é um Cão, Lobo ou Gato, apenas quero saber se vai latir.
// A medida que os requisitos mudarem, pode haver outras
// formas de latir, porém, esse trecho de código continuará operando
//
// O que se deve levar em consideração é o que o método .bark() retorna,
// uma string ou um objeto/function? deve se pensar na abstração,