{"id":18574918,"url":"https://github.com/mattsparks/the-stringler","last_synced_at":"2025-10-05T16:39:04.242Z","repository":{"id":57068550,"uuid":"62338262","full_name":"mattsparks/the-stringler","owner":"mattsparks","description":"An OOP approach to string manipulation.","archived":false,"fork":false,"pushed_at":"2019-08-28T01:24:28.000Z","size":33,"stargazers_count":34,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-21T10:38:14.342Z","etag":null,"topics":["laravel","manipulating-strings","oop","php","string-manipulation","strings"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattsparks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-30T19:51:16.000Z","updated_at":"2023-07-03T10:58:42.000Z","dependencies_parsed_at":"2022-08-24T14:54:12.257Z","dependency_job_id":null,"html_url":"https://github.com/mattsparks/the-stringler","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/mattsparks/the-stringler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattsparks%2Fthe-stringler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattsparks%2Fthe-stringler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattsparks%2Fthe-stringler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattsparks%2Fthe-stringler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattsparks","download_url":"https://codeload.github.com/mattsparks/the-stringler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattsparks%2Fthe-stringler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270856775,"owners_count":24657700,"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-08-17T02:00:09.016Z","response_time":129,"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":["laravel","manipulating-strings","oop","php","string-manipulation","strings"],"created_at":"2024-11-06T23:16:53.882Z","updated_at":"2025-10-05T16:38:59.216Z","avatar_url":"https://github.com/mattsparks.png","language":"PHP","readme":"# The Stringler\n\nA simple class to manipulate strings in an OO way. Inspired by [Spatie's String](https://github.com/spatie/string). Just built this for fun. Hope you like it.\n\n## Install\nVia composer:\n```bash\ncomposer require thestringler/manipulator\n```\n\nUsing Laravel? Checkout [The Stringler Laravel Package](https://github.com/mattsparks/the-stringler-laravel).\n\n## Methods\n### append($string)\n```php\nManipulator::make('Freak')-\u003eappend(' Out!');\n// Freak Out!\n```\n\n### camelToSnake\n```php\nManipulator::make('camelCase')-\u003ecamelToSnake();\n// camel_case\n```\n\n### camelToClass\n```php\nManipulator::make('className')-\u003ecamelToClass();\n// ClassName\n```\n\n### capitalize\n```php\nManipulator::make('hello')-\u003ecapitalize();\n// Hello\n```\n### capitalizeEach\n```php\nManipulator::make('i like toast!')-\u003ecapitalizeEach();\n// I Like Toast!\n```\n\n### custom\n```php\nManipulator::make('Some String')-\u003ecustom(function ($string) {\n    // This is just a sample, this can be achieved with existing methods,\n    // But you can do whatever string manipulation you want here.\n    return ucfirst(strtolower($string));\n});\n// Some string\n```\n\n### eachCharacter($closure)\n```php\nManipulator::make('hello')-\u003eeachCharacter(function($char) {\n    return strtoupper($char);\n});\n// HELLO\n```\n\n### eachWord($closure, $preserveSpaces = false)\n```php\nManipulator::make('hello moto')-\u003eeachWord(function($word) {\n    return strrev($word);\n});\n// ollehotom\n\nManipulator::make('hello moto')-\u003eeachWord(function($word) {\n    return strrev($word);\n}, true);\n// olleh otom\n```\n\n### getPossessive\n```php\nManipulator::make('Bob')-\u003egetPossessive();\n// Bob's\nManipulator::make('Silas')-\u003egetPossessive();\n// Silas'\n```\n\n### htmlEntities($flags = ENT_HTML5, $encoding = 'UTF-8', $doubleEncode = true)\n```php\nManipulator::make('\u0026')-\u003ehtmlEntities();\n// \u0026amp;\n```\n\n### htmlEntitiesDecode($flags = ENT_HTML5, $encoding = 'UTF-8')\n```php\nManipulator::make('\u0026amp;')-\u003ehtmlEntitiesDecode();\n// \u0026\n```\n\n### htmlSpecialCharacters($flags = ENT_HTML5, $encoding = 'UTF-8', $doubleEncode = true)\n```php\nManipulator::make('\u0026\u003c\u003e')-\u003ehtmlSpecialCharacters();\n// \u0026amp;\u0026lt;\u0026gt;\n```\n\n### lowercaseFirst\n```php\nManipulator::make('HELLO')-\u003elowercaseFirst();\n// hELLO\n```\n\n### make($string)\n```php\n// Named constructor\nManipulator::make('string');\n```\n\n### pad($length, $string, $type = null)\n```php\nManipulator::make('Hello')-\u003epad(2, '!!', STR_PAD_RIGHT);\n// Hello!!\n```\n\n### prepend($string)\n```php\nManipulator::make('is the one.')-\u003eprepend('Neo ');\n// Neo is the one.\n```\n\n### pluralize($items = null)\n```php\nManipulator::make('Potato')-\u003epluralize();\n// Potatoes\n```\n\nYou can optionally pass an array or numeric value to `pluaralize` to determine if the given string should be pluaralized.\n\n```php\n$dogs = ['Zoe', 'Spot', 'Pickles'];\nManipulator::make('Dog')-\u003epluralize($dogs);\n// Dogs\n\n$cats = ['Whiskers'];\nManipulator::make('Cat')-\u003epluralize($cats);\n// Cat\n```\n\n### nthCharacter($nth, $closure)\n```php\nManipulator::make('Wordpress')-\u003enthCharacter(5, function($character) {\n    return mb_strtoupper($character);\n});\n// WordPress\n```\n\n### nthWord($nth, $closure, $preserveSpaces = true)\n```php\nManipulator::make('Oh hello there!')-\u003enthWord(2, function($word) {\n    return mb_strtoupper($word);\n});\n// Oh HELLO there!\n```\n\n### remove($string, $caseSensitive = true)\n```php\nManipulator::make('Dog Gone')-\u003eremove('Gone');\n// Dog\n```\n\n### removeSpecialCharacters($exceptions = [])\n```php\nManipulator::make('Hello!!')-\u003eremoveSpecialCharacters();\n// Hello\nManipulator::make('Hello!!')-\u003eremoveSpecialCharacters(['!']);\n// Hello!!\n```\n\n### repeat($multiplier = 1)\n```php\nManipulator::make('la')-\u003erepeat(3);\n// lalala\n```\n\n### replace($find, $replace = '', $caseSensitive = true)\n```php\nManipulator::make('Pickles are good.')-\u003ereplace('good', 'terrible');\n// Pickles are terrible.\n```\n\n### reverse\n```php\nManipulator::make('Whoa!')-\u003ereverse();\n// !aohW\n```\n\n### snakeToCamel\n```php\nManipulator::make('snake_case')-\u003esnakeToCamel();\n// snakeCase\n```\n\n### snakeToClass\n```php\nManipulator::make('class_name')-\u003esnakeToClass();\n// ClassName\n```\n\n### stripTags($allowed = '')\n```php\nManipulator::make('\u003ci\u003eHello\u003c/i\u003e')-\u003estripTags();\n// Hello\n```\n\n### toCamelCase\n```php\nManipulator::make('camel case')-\u003etoCamelCase();\n// camelCase\n```\n\n### toL33t\n```php\nManipulator::make('Hack The Planet!')-\u003etoL33t();\n// (-)@{|\u003c +/-/€ |O7@|\\|€][!\n```\n\n### toLower\n```php\nManipulator::make('LOWER')-\u003etoLower();\n// lower\n```\n\n### toSlug\n```php\nManipulator::make('This is a slug!')-\u003etoSlug();\n// this-is-a-slug\n```\n\n### toSnakeCase\n```php\nManipulator::make('snake case')-\u003etoSnakeCase();\n// snake_case\n```\n\n### toString\nThis method just returns the string.\n\n### toUpper\n```php\nManipulator::make('upper')-\u003etoUpper();\n// UPPER\n```\n\n### trim\n```php\nManipulator::make('  trimmed  ')-\u003etrim();\n// trimmed\n```\n\n### trimBeginning\n```php\nManipulator::make('  trimmed')-\u003etrimBeginning();\n// trimmed\n```\n\n### trimEnd\n```php\nManipulator::make('trimmed  ')-\u003etrimEnd();\n// trimmed\n```\n\n### truncate($length = 100, $append = '...')\n```php\nManipulator::make('This is a sentence and will be truncated.')-\u003etruncate(10, '...');\n// This is a ...\n```\n\n### urlDecode\n```php\nManipulator::make('hello%21')-\u003eurlDecode();\n// hello!\n```\n\n### urlEncode\n```php\nManipulator::make('hello!')-\u003eurlEncode();\n// hello%21\n```\n## Chainable\n\nAll of these methods (minus `toString`) can be chained.\n\n```php\nManipulator::make('hello')-\u003etoUpper()-\u003ereverse();\n// OLLEH\n```\n\n## Contribute\nContributions are very welcome!\n\n1. Follow the [PSR-2 Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)\n2. Send a pull request.\n\nThat's pretty much it!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattsparks%2Fthe-stringler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattsparks%2Fthe-stringler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattsparks%2Fthe-stringler/lists"}