PHPackages                             ajaminov/trip-sorter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ajaminov/trip-sorter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ajaminov/trip-sorter
====================

Demo package for sorting cards.

09PHP

Since Aug 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Superwow3d/trip-sorter)[ Packagist](https://packagist.org/packages/ajaminov/trip-sorter)[ RSS](/packages/ajaminov-trip-sorter/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Trip Sorter
===========

[](#trip-sorter)

This package sorts a set of boarding passes containing information about the type of transport, departure point and destination. I suggested that the departure and destination points can not be repeated. Also, the journey can not be looped (the departure point coincides with the destination).

Getting Started
---------------

[](#getting-started)

It is possible to install package in [composer](https://getcomposer.org/download/) "ajaminov/trip-sorter", or just download repository.

### Installing

[](#installing)

For download use

```
git clone https://github.com/Superwow3d/trip-sorter.git

```

Run 'composer install' in project root directory

```
composer install

```

After that you can test it

```
composer test

```

### Alternative

[](#alternative)

Run in terminal

```
composer require ajaminov/trip-sorter dev-master

```

Requires php: &gt;=7.0

How to execute
--------------

[](#how-to-execute)

As it was said earlier, you can install the package through the composer. But if you downloaded the repository, then just run the trip-sorter.php file via composer

```
composer execute

```

**TripSorter\\MovableBuilder**

Set departure and destination points by methods **setFrom** and **setTo** respectively

Select transport with methods **byTrain** / **byAirplane** / **byBus**

Set seat, transport number and other information.

Method **build** will return you instance of **Movable** class (boarding pass).

Create as many as you like for boarding passes and sort it with method **sortCards** of **\\TripSorter\\Sorter\\Sorter** class, which returns array of string.

For example

```
$cards = [];
try {
    $cards[] = (new MovableBuilder())->setFrom('Madrid')
        ->setTo('Barcelona')
        ->byAirplane()
        ->setSeat('44F')
        ->setFlightNumber('MAU113')
        ->setGate('F')
        ->build();
    $cards[] = (new MovableBuilder())->setFrom('Barcelona')
        ->setTo('Warsaw')
        ->byTrain()
        ->setSeat('23A')
        ->setTrainNumber('44')
        ->build();
    $cards[] = (new MovableBuilder())->setFrom('Astana')
        ->setTo('Madrid')
        ->byAirplane()
        ->setSeat('12')
        ->setFlightNumber('44')
        ->addBaggage('123')
        ->setGate('T2')
        ->build();
    $cards[] = (new MovableBuilder())->setFrom('Pavlodar')
        ->setTo('Astana')
        ->byBus()
        ->setSeat('1C')
        ->build();
} catch (MovableBuilder\IncorrectDataException $e) {}

$sorter = new \TripSorter\Sorter\Sorter();
$cards = $sorter->sortCards($cards);

/** @var \TripSorter\Movable $card */
foreach ($cards as $card) {
    echo $card . PHP_EOL;
}

```

This code will output next

```
1. Take the airport bus from Pavlodar to Astana. Sit in seat 1C
2. From Astana, take flight 44 to Madrid. Gate T2, seat 12. Baggage drop at ticket counter 123.
3. From Madrid, take flight MAU113 to Barcelona. Gate F, seat 44F.
4. Take train from Barcelona to Warsaw. Sit in seat 23A
5. You have arrived at your final destination

```

How to extend
-------------

[](#how-to-extend)

API uses **Buildable** interface with method **build** which returns **Movable** class.

For example, you can create transport Horse.

```
class Horse extends \TripSorter\Movable
{
    public function __construct(string $from, string $to)
    {
        $this->from = $from;
        $this->to = $to;
    }

    public function display(): string
    {
        return 'Ride horse from ' . $this->from . ' to ' . $this->to . '.';
    }
}

class HorseBuilder implements MovableBuilder\Buildable
{
    private $from;
    private $to;

    public function setFrom(string $from): self
    {
        $obj = clone $this;
        $obj->from = $from;
        return $obj;
    }

    /**
     * @param string $to
     * @return MovableBuilder
     */
    public function setTo(string $to): self
    {
        $obj = clone $this;
        $obj->to = $to;
        return $obj;
    }

    public function build(): \TripSorter\Movable
    {
        return new Horse($this->from, $this->to);
    }
}

```

And use it

```
$card = (new HorseBuilder()
    ->setFrom('Morrowind')
    ->setTo('Oblivion')
    ->build();

```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5483331?v=4)[Amir Jaminov](/maintainers/Superwow3d)[@Superwow3d](https://github.com/Superwow3d)

---

Top Contributors

[![Superwow3d](https://avatars.githubusercontent.com/u/5483331?v=4)](https://github.com/Superwow3d "Superwow3d (17 commits)")

### Embed Badge

![Health badge](/badges/ajaminov-trip-sorter/health.svg)

```
[![Health](https://phpackages.com/badges/ajaminov-trip-sorter/health.svg)](https://phpackages.com/packages/ajaminov-trip-sorter)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
