2017 © Pedro PelĂĄez
 

library railway

image

martinezdelariva/railway

  • Saturday, August 5, 2017
  • by martinezdelariva
  • Repository
  • 1 Watchers
  • 4 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 160 % Grown

The README.md

Railway

Build Status, (*1)

This library is based on a post from (Scott Wlaschin)[https://fsharpforfunandprofit.com/posts/recipe-part2/] in order to bring Railway Oriented Programming to PHP., (*2)

Installation

Install it using Composer, (*3)

composer require martinezdelariva/railway 

Motivation

Typically every use case receives a request and produces a response. The use case passes for several steps until gets the final response to be returned. Handle every error scenario could be tedious and difficult to read., (*4)

Either

In order to have a type that works with any workflow, we borrow the type Either from functional programming:, (*5)

Either, (*6)

This object acts as a switch, where left means failure and the right means success., (*7)

Railway Naming Convention

Railways have switches ("points" in the UK) for directing trains onto a different track. We can think of these “Success/Failure” functions as railway switches., (*8)

  • One track function: it has 1 input and 1 output.

One track, (*9)

  • Two track function: it has 2 input (Either) and 2 output (Either).

Two track, (*10)

  • Switch: it has 1 input and 2 output (Either).

Switch, (*11)

Functions

Please find below the list of functions which connects switch together:, (*12)

Map

1-1 : 2-2, (*13)

Converts one track function into two track function., (*14)

Map, (*15)

Lift

Converts one track function into switch., (*16)

1-1 : 1-2, (*17)

Lift, (*18)

Bind

Converts switch into two track function., (*19)

1-2 : 2-2, (*20)

Bind, (*21)

Unite

Join two switches into another switch., (*22)

1-2 and 1-2 : 1-2, (*23)

Unite, (*24)

Tee

Dead-function to one track function., (*25)

Tee, (*26)

TryCatch

Handling exceptions. Convert one track function into switch., (*27)

1-1 : 1-2, (*28)

Try Catch, (*29)

Plus

Combines switch functions in parallel., (*30)

1-2 + 1-2 : 1-2, (*31)

Plus, (*32)

DoubleMap

Handles both tracks, converting one track into two track function., (*33)

1-1 : 2-2, (*34)

Double Map, (*35)

The Versions

05/08 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

functional railway railway oriented programming

05/08 2017

v1.0

1.0.0.0

  Sources   Download

MIT

The Development Requires

functional railway railway oriented programming