Skip to content

Instantly share code, notes, and snippets.

<?php
namespace League\Event;
interface ListenerInterface
{
/**
* Handle an event.
*
* @param EventInterface $event
<?php
namespace League\Event;
abstract class AbstractListener implements ListenerInterface
{
/**
* {@inheritdoc}
*/
public function isListener($listener)
trait PartialListener
{
/**
* {@inheritdoc}
*/
public function isListener($listener)
{
return $this === $listener;
}
}
@hannesvdvreken
hannesvdvreken / CsvWriter.php
Created September 28, 2015 13:07
Trait's setTransformer method
private function setTransformer(TransformerInterface $transformer)
{
$this->writer->insertOne($transformer->getHeaders());
$this->writer->addFormatter([$transformer, 'transform']);
}
@hannesvdvreken
hannesvdvreken / CsvWriter.php
Created September 28, 2015 13:06
Trait with setup method
trait CsvWriter
{
private $file;
private $writer;
private function setup()
{
$this->file = new SplTempFileObject();
$this->writer = Writer::createFromFileObject($this->file);
}
@hannesvdvreken
hannesvdvreken / CsvWriter.php
Created September 28, 2015 13:05
Simple trait
trait CsvWriter
{
private $file;
private $writer;
}
abstract class CsvExporter
{
protected $repository;
protected $file;
protected $writer;
protected $parameters;
abstract class AbstractRepository
{
public function __construct(Model $models)
{
$this->models = $models;
}
public function get(array $options = [])
{
if (isset($options['sort'])) {
<?php
class ResolvableMiddleware
{
public function __construct(ContainerInterface $container, $classname)
{
$this->container = $container;
$this->classname = $classname;
}
# Show graph of commits with abbreviated hashes and commit messages
git log --oneline --decorate --all --graph
# Show entire repo's changes one at a time to decide which to stage and which not.
git add -p
# Record conflict resolving. https://git-scm.com/blog/2010/03/08/rerere.html
git config --global rerere.enabled true
# Merge, but always add an extra merge commit instead of just moving the branch reference.