{"id":13828171,"url":"https://github.com/ICanBoogie/Inflector","last_synced_at":"2025-07-09T05:31:45.375Z","repository":{"id":7420233,"uuid":"8754635","full_name":"ICanBoogie/Inflector","owner":"ICanBoogie","description":"A multilingual inflector that transforms words from singular to plural, underscore to camel case, and formats strings in various ways.","archived":false,"fork":false,"pushed_at":"2023-03-12T18:43:04.000Z","size":146,"stargazers_count":214,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-22T08:44:14.101Z","etag":null,"topics":["camelcase","inflector","pluralization","underscore"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ICanBoogie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-13T14:56:46.000Z","updated_at":"2024-06-18T11:14:17.418Z","dependencies_parsed_at":"2024-06-18T11:14:17.150Z","dependency_job_id":"7f8a5658-0314-4fc2-ac1c-e912c54d0a0a","html_url":"https://github.com/ICanBoogie/Inflector","commit_stats":{"total_commits":73,"total_committers":16,"mean_commits":4.5625,"dds":0.3835616438356164,"last_synced_commit":"0288676d1cd48899386f8bbe50643d3ade5dc13b"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICanBoogie%2FInflector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICanBoogie%2FInflector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICanBoogie%2FInflector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ICanBoogie%2FInflector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ICanBoogie","download_url":"https://codeload.github.com/ICanBoogie/Inflector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224837142,"owners_count":17378180,"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","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":["camelcase","inflector","pluralization","underscore"],"created_at":"2024-08-04T09:02:35.149Z","updated_at":"2024-11-20T07:31:33.769Z","avatar_url":"https://github.com/ICanBoogie.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Inflector\n\n[![Release](https://img.shields.io/packagist/v/ICanBoogie/Inflector.svg)](https://packagist.org/packages/icanboogie/inflector)\n[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/Inflector/master.svg)](https://scrutinizer-ci.com/g/ICanBoogie/Inflector)\n[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/Inflector/master.svg)](https://coveralls.io/r/ICanBoogie/Inflector)\n[![Packagist](https://img.shields.io/packagist/dm/icanboogie/inflector.svg?maxAge=2592000)](https://packagist.org/packages/icanboogie/inflector)\n\nA multilingual inflector that transforms words from singular to plural, underscore to camel case, and formats strings in\nvarious ways. Inflections are localized, the default english inflections for pluralization, singularization, and\nuncountable words are kept in [lib/Inflections/en.php](lib/Inflections/en.php).\n\nInflections are currently available for the following languages:\n\n- English (`en`)\n- French (`fr`)\n- Norwegian Bokmal (`nb`)\n- Portuguese (`pt`)\n- Spanish (`es`)\n- Turkish (`tr`)\n\n\n\n#### Installation\n\n```bash\ncomposer require icanboogie/inflector\n```\n\n\n\n## Usage\n\nThese are some examples of the inflector with the `en` locale (default).\n\n```php\n\u003c?php\n\nuse ICanBoogie\\Inflector;\n\n$inflector = Inflector::get(Inflector::DEFAULT_LOCALE);\n# or\n$inflector = Inflector::get('en');\n# or\n$inflector = Inflector::get();\n\n# pluralize\n\n$inflector-\u003epluralize('post');                       // \"posts\"\n$inflector-\u003epluralize('child');                      // \"children\"\n$inflector-\u003epluralize('sheep');                      // \"sheep\"\n$inflector-\u003epluralize('words');                      // \"words\"\n$inflector-\u003epluralize('CamelChild');                 // \"CamelChildren\"\n\n# singularize\n\n$inflector-\u003esingularize('posts');                    // \"post\"\n$inflector-\u003esingularize('children');                 // \"child\"\n$inflector-\u003esingularize('sheep');                    // \"sheep\"\n$inflector-\u003esingularize('word');                     // \"word\"\n$inflector-\u003esingularize('CamelChildren');            // \"CamelChild\"\n\n# camelize\n\n$inflector-\u003ecamelize('active_model', Inflector::UPCASE_FIRST_LETTER);\n# or\n$inflector-\u003ecamelize('active_model');\n// 'ActiveModel'\n\n$inflector-\u003ecamelize('active_model', Inflector::DOWNCASE_FIRST_LETTER);\n// 'activeModel'\n\n$inflector-\u003ecamelize('active_model/errors');\n// 'ActiveModel\\Errors'\n\n$inflector-\u003ecamelize('active_model/errors', Inflector::DOWNCASE_FIRST_LETTER);\n// 'activeModel\\Errors'\n\n# underscore\n\n$inflector-\u003eunderscore('ActiveModel');               // 'active_model'\n$inflector-\u003eunderscore('ActiveModel\\Errors');        // 'active_model/errors'\n$inflector-\u003eunderscore('Less Active Phrase');        // 'less_active_phrase'\n$inflector-\u003eunderscore('Number 1 Test');             // 'number_1_test'\n$inflector-\u003eunderscore('Johnny5 Still Alive');       // 'johnny5_still_alive'\n$inflector-\u003eunderscore('Lots   of   Spaces');        // 'lots_of_spaces'\n\n# humanize\n\n$inflector-\u003ehumanize('employee_salary');             // \"Employee salary\"\n$inflector-\u003ehumanize('author_id');                   // \"Author\"\n\n# titleize\n\n$inflector-\u003etitleize('man from the boondocks');      // \"Man From The Boondocks\"\n$inflector-\u003etitleize('x-men: the last stand');       // \"X Men: The Last Stand\"\n$inflector-\u003etitleize('TheManWithoutAPast');          // \"The Man Without A Past\"\n$inflector-\u003etitleize('raiders_of_the_lost_ark');     // \"Raiders Of The Lost Ark\"\n\n# ordinal\n\n$inflector-\u003eordinal(1);                              // \"st\"\n$inflector-\u003eordinal(2);                              // \"nd\"\n$inflector-\u003eordinal(1002);                           // \"nd\"\n$inflector-\u003eordinal(1003);                           // \"rd\"\n$inflector-\u003eordinal(-11);                            // \"th\"\n$inflector-\u003eordinal(-1021);                          // \"st\"\n\n# ordinalize\n\n$inflector-\u003eordinalize(1);                           // \"1st\"\n$inflector-\u003eordinalize(2);                           // \"2nd\"\n$inflector-\u003eordinalize(1002);                        // \"1002nd\"\n$inflector-\u003eordinalize(1003);                        // \"1003rd\"\n$inflector-\u003eordinalize(-11);                         // \"-11th\"\n$inflector-\u003eordinalize(-1021);                       // \"-1021st\"\n\n# uncountable\n\n$inflector-\u003eis_uncountable(\"advice\");                // true\n$inflector-\u003eis_uncountable(\"weather\");               // true\n$inflector-\u003eis_uncountable(\"cat\");                   // false\n```\n\nHelpers makes it easy to use default locale inflections.\n\n```php\n\u003c?php\n\nnamespace ICanBoogie;\n\necho pluralize('child');                             // \"children\"\necho pluralize('genou', 'fr');                       // \"genoux\"\necho singularize('lærere', 'nb');                    // \"lærer\"\necho pluralize('üçgen', 'tr');                       // \"üçgenler\"\n```\n\n\n## About inflections\n\nInflections are localized, the configurators are kept in [lib/Inflections/en.php](lib/Inflections/en.php). Since v2.1,\nthese configurators are auto-loaded classes, which means, in theory, you could add your own or overwrite those already\ndefined by specifying another `ICanBoogie\\\\Inflections\\\\` in your `composer.json` file.\n\n\n\n## Acknowledgements\n\nMost of the code and documentation was adapted from [Ruby On Rails](http://rubyonrails.org/)'s\n[Inflector](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html) and\n[David Celis](https://github.com/davidcelis)' [inflections](https://github.com/davidcelis/inflections).\n\nSignificant differences:\n\n- Better support of accentuated characters.\n- The Ruby module separator `::` as been replaced by the PHP namespace separator `\\`.\n- The plural of \"octopus\" is \"octopuses\" (not \"octopi\"), the plural of \"virus\" is \"viruses\"\n  (not viri) and the pural of \"cow\" is \"cows\" (not \"kine\").\n- The following methods have been removed: `tableize`, `classify`, `demodulize`,\n  `constantize`, `deconstantize` and `foreign_key`. They can be easily implemented in specific inflectors.\n- Added the `hyphenate` method, which is a combination of `underscore` and `dasherize`.\n- One specifies `true` rather than `false` to `camelize()` to downcase the first letter of the camel cased string.\n\n\n\n## Getting started\n\n**Inflector** expects to work in UTF-8, which is the default encoding character set starting\nPHP 5.6, for older versions please use `mb_internal_encoding()` as follows:\n\n```php\n\u003c?php\n\nnamespace ICanBoogie;\n\n// …\n\nmb_internal_encoding('UTF-8');\n\ntitleize(\"été_aux_âmes_inouïes\"); // Été Aux Âmes Inouïes\n```\n\n\n\n----------\n\n\n\n## Continuous Integration\n\nThe project is continuously tested by [GitHub actions](https://github.com/ICanBoogie/Inflector/actions).\n\n[![Tests](https://github.com/ICanBoogie/Inflector/workflows/test/badge.svg?branch=master)](https://github.com/ICanBoogie/Inflector/actions?query=workflow%3Atest)\n[![Static Analysis](https://github.com/ICanBoogie/Inflector/workflows/static-analysis/badge.svg?branch=master)](https://github.com/ICanBoogie/Inflector/actions?query=workflow%3Astatic-analysis)\n[![Code Style](https://github.com/ICanBoogie/Inflector/workflows/code-style/badge.svg?branch=master)](https://github.com/ICanBoogie/Inflector/actions?query=workflow%3Acode-style)\n\n\n\n## Code of Conduct\n\nThis project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project and its\ncommunity, you are expected to uphold this code.\n\n\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n\n\n## License\n\n**icanboogie/inflector** is released under the [BSD-3-Clause](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FICanBoogie%2FInflector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FICanBoogie%2FInflector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FICanBoogie%2FInflector/lists"}