PHPackages                             ngomafortuna/list-formatter - 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. ngomafortuna/list-formatter

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

ngomafortuna/list-formatter
===========================

Formatter from composite datas to string list. This library accepts lists in array or database format and converts them into strings where each item is separated by commas. This library also sorts a composite list (array/object) in ascending and descending order. (Formatador de dados compostos para string. Esta biblioteca recebe listas em formato de array ou base de dados e converte string em onde cada item é separado por vígulas. Esta biblioteca também ordena uma lista composta (array/object) de forma crescente e decrescente.)

v1.1(1mo ago)010BSD-3-ClausePHPPHP &gt;=8.0

Since Jun 8Pushed 1mo agoCompare

[ Source](https://github.com/ngomaf/list-formatter)[ Packagist](https://packagist.org/packages/ngomafortuna/list-formatter)[ RSS](/packages/ngomafortuna-list-formatter/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (5)Used By (0)

List formatter
==============

[](#list-formatter)

List formatter is a component with three main functions: (1) convert data in list format (array/object) to text, separating them by commas; (2) sort in ascending or descending order; and (3) convert lists from array format to object and vice-versa.

(Formatador de listas é um componente, com três funções principais (1) converter dados em formato de lista (array/objecto) para texto separando-os por vírgulas, (2) Ordenar de forma crescente ou decrescente e (3) converter listas do formato de array para objecto e vice-versa)

This component have 3 features:

1. ListToString: To convert a list in array or object format into a string with each item separated by a comma, or also to add a hyperlink to each item. (para converter lista em formato de array ou objecto em string com cada item separado por vírgula ou ainda colocar um hiperlink para cada item).

    - get: Returns a string, with each item separated by a comma. (retorna um string, com cada item separado por vígula)
    - getWithLink: Returns a string, with each item as a hyperlink separated by a comma. (retorna um string, com cada item com hiperlink separado por vírgula)
2. Order: to order array or object list, for two options ascending end descending. (Para ordenar elementos de uma lista, de forma crescente ou decrecente).

    - get: return list in asc order (retorna uma lista em ordem crescente)
    - getReverse: return list in desc order (retorna uma lista em ordem decrescente)
3. ToListType: Converts object to array and vice-versa. (Converte objecto em array e vice-versa)

    - toObject
    - toArray

Require
-------

[](#require)

Necessary PHP 8.0 or more (Necessário PHP 8.0 ou superior)

Install
-------

[](#install)

composer require ngomafortuna/list-formatter

Syntax and mode of use
----------------------

[](#syntax-and-mode-of-use)

```
ListToString::get($array, 'array_key');
ListToString::getWithLink($array, ['array_key', 'array_key'], 'url');
```

```
Order::get($array, 'array_key');
Order::getReverse($array, 'array_key');
```

```
ToListType::toObject($array);
ToListType::toArray($object);
```

Example
-------

[](#example)

```
use Ngomafortuna\ListFormatter\ListToString;
use Ngomafortuna\ListFormatter\Order;
use Ngomafortuna\ListFormatter\ToListType;

$arrayLIst = [
    ['title' => 'Socieda', 'slug'=> 'sociedade','date' => '2024-76-06'],
    ['title' => 'Vestimentas', 'slug'=> 'vestimentas', 'date' => '2024-06-06'],
    ['title' => 'Cultura', 'slug'=> 'cultura','date' => '2025-06-06'],
];
```

### Transforme array or object list to string

[](#transforme-array-or-object-list-to-string)

```
$list = ListToString::get($arrayLIst, 'title');
$list_with_link = ListToString::getWithLink($arrayLIst, ['title', 'slug'], 'https://www.minharosa.ao');

var_dump($list, $list_with_link);
```

Result

```
string(29) "Socieda, Vestimentas e Cultura"

string(176) "Socieda, Vestimentas e Cultura"
```

### Order array or object list

[](#order-array-or-object-list)

```
$order = Order::get($arrayLIst, 'title');
$order_reverse = Order::getReverse($arrayLIst, 'title');

var_dump($order, $order_reverse);
```

Result

```
array(3) {
  [0]=>
  array(3) {
    ["title"]=>
    string(7) "Cultura"
    ["slug"]=>
    string(7) "cultura"
    ["date"]=>
    string(10) "2025-06-06"
  }
  [1]=>
  array(3) {
    ["title"]=>
    string(7) "Socieda"
    ["slug"]=>
    string(9) "sociedade"
    ["date"]=>
    string(10) "2024-76-06"
  }
  [2]=>
  array(3) {
    ["title"]=>
    string(11) "Vestimentas"
    ["slug"]=>
    string(11) "vestimentas"
    ["date"]=>
    string(10) "2024-06-06"
  }
}

array(3) {
  [0]=>
  array(3) {
    ["title"]=>
    string(11) "Vestimentas"
    ["slug"]=>
    string(11) "vestimentas"
    ["date"]=>
    string(10) "2024-06-06"
  }
  [1]=>
  array(3) {
    ["title"]=>
    string(7) "Socieda"
    ["slug"]=>
    string(9) "sociedade"
    ["date"]=>
    string(10) "2024-76-06"
  }
  [2]=>
  array(3) {
    ["title"]=>
    string(7) "Cultura"
    ["slug"]=>
    string(7) "cultura"
    ["date"]=>
    string(10) "2025-06-06"
  }
}
```

### Convert array list to object end object list to array

[](#convert-array-list-to-object-end-object-list-to-array)

```
$conv_to_object = ToListType::toObject($arrayLIst);

// create object to convert
$listObj = [];
foreach($arrayLIst as $item) {
    $objModel = new \stdClass();
    $objModel->title = $item['title']; $objModel->slug =  $item['slug']; $objModel->date = $item['date']; $listObj[] = $objModel;
}
$listObj = (object) $listObj;
$conv_to_array = ToListType::toArray($listObj);

var_dump($conv_to_object, $conv_to_array);
```

Result

```
object(stdClass)#6 (3) {
  ["0"]=>
  object(stdClass)#2 (3) {
    ["title"]=>
    string(7) "Socieda"
    ["slug"]=>
    string(9) "sociedade"
    ["date"]=>
    string(10) "2024-76-06"
  }
  ["1"]=>
  object(stdClass)#4 (3) {
    ["title"]=>
    string(11) "Vestimentas"
    ["slug"]=>
    string(11) "vestimentas"
    ["date"]=>
    string(10) "2024-06-06"
  }
  ["2"]=>
  object(stdClass)#5 (3) {
    ["title"]=>
    string(7) "Cultura"
    ["slug"]=>
    string(7) "cultura"
    ["date"]=>
    string(10) "2025-06-06"
  }
}

array(3) {
  [0]=>
  array(3) {
    ["title"]=>
    string(7) "Socieda"
    ["slug"]=>
    string(9) "sociedade"
    ["date"]=>
    string(10) "2024-76-06"
  }
  [1]=>
  array(3) {
    ["title"]=>
    string(11) "Vestimentas"
    ["slug"]=>
    string(11) "vestimentas"
    ["date"]=>
    string(10) "2024-06-06"
  }
  [2]=>
  array(3) {
    ["title"]=>
    string(7) "Cultura"
    ["slug"]=>
    string(7) "cultura"
    ["date"]=>
    string(10) "2025-06-06"
  }
}
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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.

###  Release Activity

Cadence

Every ~120 days

Total

4

Last Release

30d ago

Major Versions

v0.1 → v1.02026-05-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf130e70a6c13b7f54c1f1d9aa4231bc04f544afa931e9e602cdfac3a6891e7a?d=identicon)[ngomafortuna](/maintainers/ngomafortuna)

---

Top Contributors

[![ngomaf](https://avatars.githubusercontent.com/u/172862580?v=4)](https://github.com/ngomaf "ngomaf (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngomafortuna-list-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/ngomafortuna-list-formatter/health.svg)](https://phpackages.com/packages/ngomafortuna-list-formatter)
```

PHPackages © 2026

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