Skip to content

Instantly share code, notes, and snippets.

View thiagomarini's full-sized avatar

Thiago Marini thiagomarini

View GitHub Profile
@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();
@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 / 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 / readme.sh
Created October 29, 2018 16:10
How to install supervisor on Amazon Linux
# Install it as a yum package instead of throgh pip (will save you from lots of hassle)
# first get epel
sudo amazon-linux-extras install epel
# then install supervisor
sudo yum install supervisor
@thiagomarini
thiagomarini / laravel_spaguetti_controller.php
Last active December 6, 2018 08:30
Laravel Spaghetti Example
<?php
/**
* Create new shipment barcode
*
* $param Request $request
* @return void
**/
public function createShipmentBarcode(Request $request)
{
// validate required fields
@thiagomarini
thiagomarini / service_example.php
Last active December 20, 2018 12:22
Weengs Service Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Exceptions\BusinessException;
use Weengs\Models\User\Onboarding;
use Weengs\Models\User\User;
use Weengs\Services\Common\BaseService;
use Weengs\Services\Common\RequestInterface;
use Weengs\Services\Common\ResponseInterface;
@thiagomarini
thiagomarini / service_request_example.php
Last active December 20, 2018 12:16
Weengs Service Request Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Exceptions\ValidationException;
use Weengs\Services\Common\BaseServiceRequest;
class Request extends BaseServiceRequest
{
/**
@thiagomarini
thiagomarini / service_response_example.php
Last active December 20, 2018 12:15
Weengs Service Response Example
<?php
namespace Weengs\Services\Merchant\Onboarding\RequestPhoneCall;
use Weengs\Models\User\User;
use Weengs\Services\Common\BaseServiceResponse;
class Response extends BaseServiceResponse
{
/**
@thiagomarini
thiagomarini / laravel_service_usage_controller.php
Last active December 20, 2018 12:23
Service Usage in Controller Example
<?php
/**
* Requests a call from the sales team
*
* @method PUT
* @param Request $request
* @param int $userId
* @param RequestPhoneCall\Service $requestCall
*
@thiagomarini
thiagomarini / weengs_data_fecher.php
Created December 6, 2018 09:11
Data Fetcher Example
<?php
namespace Weengs\DataFetcher\Collections\Admin;
use Weengs\DataFetcher\DataFetcherInterface;
use Weengs\Models\WmsUser\App;
class ListApps implements DataFetcherInterface
{
/**