Travel class shorts your unordered boarding cards. Each ticket must have destination and source. vehicle, seat, gate members are not mandatory.
- PHP 5.3
- Any kind of *nix OS
- You can use ArraySort to sort anything, not only boarding cards.
- You can create new type of cards like plane, train, bus or whatever you want. (Default: CommonCard)
- You can able to create a gift class that you can give a track to the your shipping.
- If you would like you can create another kind of sort algorithm by extending SortInterface.
doc
└── [Documentation]
test
└── index.php
src
├── bootstrap.php
└── lib
└── tripsort
├── assets
│ ├── CardAbstract.php
│ ├── CardFactory.php
│ ├── TransportableAbstract.php
│ ├── cards
│ │ └── CommonCard.php
│ └── transportable
│ └── Person.php
├── modules
│ └── travel
│ └── Travel.php
└── utils
├── interfaces
│ └── SortInterface.php
└── sorters
└── ArraySort.php
$ php test/index.php
require_once 'src/bootstrap.php';
$tickets = array(
CardFactory::create(array(
'source' => 'Metro Station',
'destination' => 'Dubai Airport',
'vehicle' => 'metro',
'seat' => null,
'gate' => null
)),
CardFactory::create(array(
'source' => 'Marina',
'destination' => 'Metro Station',
'vehicle' => 'taxi',
'seat' => null,
'gate' => null
))
);
$passengers = array(
new Person('Abby'),
new Person('Bob'),
new Person('Alice')
);
$travel = new Travel($passengers, $tickets);
$route = $travel->sortTickets()->getTickets();
$passenger = $travel->getPassengers();
$route will be an array of the ordered tickets. If you would like you can also get passengers by calling getPassengers() method like above.
Please check documentation for more information.