Skip to content

Instantly share code, notes, and snippets.

View thiagomarini's full-sized avatar

Thiago Marini thiagomarini

View GitHub Profile
@thiagomarini
thiagomarini / tips.php
Created February 10, 2018 10:11
PHP array of The Pragmatic Programmer tips so you can slack/email them or do whatever you want to spread some good programming tips ;)
<?php
/**
* Tips from The Pragmatic Programmer
* @var array
*/
$tips = [
[
'title' => 'Care About Your Craft',
'message' => 'Why spend your life developing software unless you care about doing it well?'
@thiagomarini
thiagomarini / CarrierServices.php
Last active November 1, 2017 11:48
Example of interface with methods receiving
<?php
/**
* The implementation will know how to deal with RoyalMail, DHL, DPD etc...
*/
interface CarrierServices
{
/**
* @param LabelRequest $labelRequest
* @return LabelResponse
* @throws CarrierException
@thiagomarini
thiagomarini / usage.php
Last active September 12, 2017 14:10
Usage in a nutshell
<?php
$reducers = [
'create' => [
'1.0' => function (array $currentState, array $actionData): ?array {
# Calculate new state in here.
# Things you should never do inside a reducer:
# - Mutate its arguments;
# - Perform side effects like API calls and routing transitions;
# - Call non-pure functions, e.g. $object->method();