{"id":17087393,"url":"https://github.com/dakujem/shorts","last_synced_at":"2025-10-10T20:41:12.243Z","repository":{"id":56961496,"uuid":"211396144","full_name":"dakujem/shorts","owner":"dakujem","description":"🩳 A PHP tool to shorten or limit person names in length or create initials.","archived":false,"fork":false,"pushed_at":"2020-01-06T12:28:30.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-24T22:26:12.989Z","etag":null,"topics":["formatters","initials","names","shortener","unicode"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dakujem.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-27T20:23:41.000Z","updated_at":"2020-11-11T14:41:58.000Z","dependencies_parsed_at":"2022-08-21T10:20:34.345Z","dependency_job_id":null,"html_url":"https://github.com/dakujem/shorts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dakujem/shorts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakujem%2Fshorts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakujem%2Fshorts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakujem%2Fshorts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakujem%2Fshorts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dakujem","download_url":"https://codeload.github.com/dakujem/shorts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakujem%2Fshorts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005273,"owners_count":26083863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatters","initials","names","shortener","unicode"],"created_at":"2024-10-14T13:32:58.929Z","updated_at":"2025-10-10T20:41:12.228Z","avatar_url":"https://github.com/dakujem.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🩳 shorts\n\n![PHP from Packagist](https://img.shields.io/packagist/php-v/dakujem/shorts)\n[![Build Status](https://travis-ci.org/dakujem/shorts.svg?branch=master)](https://travis-ci.org/dakujem/shorts)\n![Nature Friendly](https://img.shields.io/badge/nature%20%F0%9F%8C%B3-friendly%20%F0%9F%92%9A-green)\n\n\nUse this tool to shorten or limit personal names to desired length, or to use initials instead of a full name.\\\nSupports _Unicode_ / UTF-8 names.\n\n- limit / cap name length (with the aim to keep the name as legible as possible):\n    ```\n    | John Roland Reuel Tolkien |\n    | --\u003e John R. Reuel Tolkien |   # last name priority\n    | -----\u003e John R. R. Tolkien |\n    | -------\u003e J. R. R. Tolkien |\n    | ---------\u003e J.R.R. Tolkien |\n    | -----------\u003e John Tolkien |\n    | ---------------\u003e J.R.R.T. |\n    | -------------------\u003e JRRT |\n    | ---------------------\u003e JT |\n    |                           | \n    | John Roland Reuel Tolkien |\n    | John R. R. Tolkien \u003c----- |   # first name priority\n    | John R. R. T. \u003c---------- |\n    | John R.R.T. \u003c------------ |\n    | J.R.R.T. \u003c--------------- |\n    | JRRT \u003c------------------- |\n    | JT \u003c--------------------- |\n    ```\n- shorten a name using initials for part of the name (no length constraint):\n    ```\n    John Roland Reuel Tolkien:\n  \n    - J. R. R. Tolkien\n    - John R. R. T.\n    ```\n- create initials (configurable separator):\n  ```\n  - JRRT\n  - J. R. R. T.\n  ```\n\n\u003e well i could not google out anything reasonable in well over 60 minutes so i decided to code it in less than that. how silly i was...\n\n\n## TODO / in progress\n\nThe features and the public interface are in place.\nThe code is still ugly, don't fret. 🙊\n\nI'm also deciding how to make it possible\nfor a custom name parser to be provided on the fly/by configuration,\nso that special cases (like compound names) can easily be supported.\nBear with me. 🐻\n\n\n**Supported**:\n- unicode names\n- arbitrary length\n\n\nWhat is **not (yet) supported**:\n- compound surnames (sorry folks, this may come later)\n- non-word characters will be lost\n    - `Bull, John`\n- academic and other titles\n    - `Bc. Foo Bar, Dr.Sc.`\n    - `John Bull, Sr.`\n- other writing systems than latin (may the will work, i'm just not testing them)\n\nYou will need to handle these yourself before/after passing them through the shortener.\n\n\n## Usage\n\nLimit (cap) names to desired lengths:\n```php\nShorts::cap('Pablo Escobar', 10); // \"P. Escobar\"\nShorts::cap('Pablo Escobar', 2); // \"PE\"\n\nShorts::cap('John Ronald Reuel Tolkien', 20); // \"John R. R. Tolkien\"\nShorts::cap('John Ronald Reuel Tolkien', 16); // \"J. R. R. Tolkien\"\nShorts::cap('John Ronald Reuel Tolkien', 15); // \"J.R.R. Tolkien\"\nShorts::cap('John Ronald Reuel Tolkien', 8);  // \"J.R.R.T.\"\nShorts::cap('John Ronald Reuel Tolkien', 4);  // \"JRRT\"\n```\nThe above will try to keep the **last name legible**, unless the limit is too strict.\\\nInverse version that will try to keep the **first name legible** is also available:\n```php\nShorts::cap('Pablo Escobar', 10, Shorts::FIRST_NAME); // \"Pablo E.\"\n```\n\nShrink names using initials except for the last name:\n```php\nShorts::shrink('John Ronald Reuel Tolkien'); // \"J. R. R. Tolkien\"\nShorts::shrink('Hugo Ventil');               // \"H. Ventil\"\n```\n\nShrink names using initials except for the first name:\n```php\nShorts::shrink('John Ronald Reuel Tolkien', Shorts::FIRST_NAME); // \"John R. R. T.\"\nShorts::shrink('Hugo Ventil', Shorts::FIRST_NAME);               // \"Hugo V.\"\n```\n\nCreate \"short\" initials:\n```php\nShorts::initials('John Ronald Reuel Tolkien'); // \"JRRT\"\nShorts::initials('Hugo Ventil');               // \"HV\"\n```\n... or \"longer\" version:\n```php\nShorts::initials('John Ronald Reuel Tolkien', '.', ' '); // \"J. R. R. T.\"\nShorts::initials('Hugo Ventil', '.', ' ');               // \"H. V.\"\n```\n\nEach of the static methods has a non-static counterpart:\n```php\nShorts::i()-\u003elimit( ... );      // Shorts::cap( ... )\nShorts::i()-\u003ereduce( ... );     // Shorts::shrink( ... )\nShorts::i()-\u003etoInitials( ... ); // Shorts::initials( ... )\n```\n\nShorts also provides the ability co create a preconfigured formatter callable for each of the methods:\n```php\nShorts::i()-\u003elimiter( ... )\nShorts::i()-\u003ereducer( ... )\nShorts::i()-\u003einitialsFormatter( ... )\n```\nThese can be used as follows:\n```php\n$fmt = Shorts::i()-\u003elimiter(20); // will limit any input to 20 chars\n$fmt('Foo Bar'); // this is equivalent to  Shorts::cap('Foo Bar', 20)\n```\n\n\u003e Note the formatters can come handy when defining filters for templating languages, like Twig or Latte.\n\n\n## Testing\n\n`$` `composer test`\n\n\n## Contributions\n\n... are always welcome. Many times it is useful to just point out a use case the author have not thought about or come across.\n\n\n## Possible future stuff\n\n- include a name parser to split the names\n    - https://github.com/joshfraser/PHP-Name-Parser\n    - https://github.com/theiconic/name-parser\n    - in fact i intend to provide a possibility to use your own explode/implode functions so that the tool is as flexible as possible\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakujem%2Fshorts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdakujem%2Fshorts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakujem%2Fshorts/lists"}