Skip to content

Instantly share code, notes, and snippets.

View sergiors's full-sized avatar
🎯
Focusing

Sérgio R Siqueira sergiors

🎯
Focusing
View GitHub Profile
<?php
namespace Inbep\Twig\Extension;
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*/
class MaskExtension extends \Twig_Extension
{
private $masks = [
'phone' => [
<?php
namespace Inbep\Component\Doctrine\DBAL\Platforms\Keywords;
use Doctrine\DBAL\Platforms\Keywords\PostgreSQL92Keywords;
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*/
class PostgreSQL92ContribKeywords extends PostgreSQL92Keywords
{
<?php
namespace Inbep\Inbep\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Sergiors\Worker\Command\CommandInterface;
use Sergiors\Worker\Command\Invoker;
class DaemoniseCommand extends Command
<?php
namespace Sergiors\LinkedList;
class LinkedList
{
private $firstNode;
private $lastNode;
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,
@sergiors
sergiors / _functions.php
Last active April 17, 2017 05:52
Reduce seu novo melhor amigo (Exemplos PHP)
<?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];
<?php
foreach ($classMetadata->getEmbeddedClasses() as $embeddedMetadata) {
if ($embeddedMetadata->isInherited()) {
continue;
}
$event->getClassMetadata()->mapField([
'fieldName' => $embeddedMetadata->getPropertyName(),
'columnName' => $embeddedMetadata->getColumnAttribute()->name,
# -*- coding: utf-8 -*-
# from sig import Provider
class Container(dict):
def __delitem__(self, name):
if self.has(name):
dict.__delitem__(self, name)
<?php
namespace Sergiors\Sergiors\Silex\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Mailgun\Mailgun;
//use Pimple/Container;
//use Pimple/ServiceProviderInterface;
<?php
function qsort(array $xs)
{
$xs = array_values($xs);
if (false === array_key_exists(1, $xs)) {
return $xs;
}