{"id":21569186,"url":"https://github.com/awssat/str-helper","last_synced_at":"2025-04-10T14:06:32.620Z","repository":{"id":62490325,"uuid":"111329905","full_name":"awssat/str-helper","owner":"awssat","description":"⚡️  A flexible \u0026 powerful string manipulation helper for PHP | using pipe method chaining ","archived":false,"fork":false,"pushed_at":"2018-09-03T19:59:20.000Z","size":42,"stargazers_count":44,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T12:47:47.957Z","etag":null,"topics":["chainable-methods","composer-package","flexible","method-chaining","packagist","php","pipe","str","str-helper","string-manipulation"],"latest_commit_sha":null,"homepage":"","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/awssat.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":"2017-11-19T20:34:22.000Z","updated_at":"2025-03-03T11:23:41.000Z","dependencies_parsed_at":"2022-11-02T11:03:24.865Z","dependency_job_id":null,"html_url":"https://github.com/awssat/str-helper","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fstr-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fstr-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fstr-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fstr-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awssat","download_url":"https://codeload.github.com/awssat/str-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231892,"owners_count":21069423,"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":["chainable-methods","composer-package","flexible","method-chaining","packagist","php","pipe","str","str-helper","string-manipulation"],"created_at":"2024-11-24T11:07:16.719Z","updated_at":"2025-04-10T14:06:32.596Z","avatar_url":"https://github.com/awssat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# str-helper\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/awssat/str-helper.svg?style=flat-square)](https://packagist.org/packages/awssat/str-helper)\n[![StyleCI](https://styleci.io/repos/111329905/shield?branch=master)](https://styleci.io/repos/111329905)\n[![Build Status](https://img.shields.io/travis/awssat/str-helper/master.svg?style=flat-square)](https://travis-ci.org/awssat/str-helper)\n\n\n⚡️  A flexible, simple \u0026 yet powerful string manipulation helper for PHP. It gives you the magic of method chaining and it's easier and shorter to be included in views. It Supports most of [PHP built-in strings functions](http://php.net/manual/en/book.strings.php) (and other useful methods like: contains, equal, append, prepend ...).\n\n\n\n```php\nstr('Hi World')-\u003ereplace(' ', '+')-\u003elower();\n```\n\n## Why use this instead of other string maniplulation packages ?\nThis is a wrapper for PHP default string functions, to provide a very poweful method chaining and conditions. \nYou don't have to learn new methods names, just use PHP functions names that you know. \n\n\n## Install/Use\nYou can install the package via composer locally in your project folder:\n\n```bash\n$ composer require awssat/str-helper\n```\n\nAfter installing it, just start using `StrHelper` class, or simply the helper function `str()`: \n\n\n## Examples\n\n```bash \nstr('Hi Hello')-\u003estrReplace(' ', '-');\n\u003e\u003e hi-hello\n```\n\n\n```bash\nstr('Hi Hello')-\u003eprepend('[')-\u003eappend(']');\n\u003e\u003e [Hi Hello]\n```\n\nIn case you want an explicit string value for conditions, use \"get\":\n```bash\nif(str('Hi')-\u003elower-\u003eget() == 'hi') {\n        echo 'yes'; \n}\n\u003e\u003e yes\n```\n\n\nThere is a \"tap\" method:\n```bash\nstr('LINK.COM')-\u003etap(function($v){ print($v); })-\u003elower();\n\u003e\u003e LINK.COM\n```\n\nfor callbacks use \"do\" method:\n```bash\nstr('\u003ca\u003elink.com\u003c/a\u003e')-\u003edo(function($string){ \n        return strip_tags($string); \n});\n\u003e\u003e link.com\n```\nor: \n```bash\nstr('\u003ca\u003elink.com\u003c/a\u003e')-\u003edo(function(){   \n        $this-\u003estripTags();\n});\n\u003e\u003e link.com\n```\n\nyou may notice using camelCase instead of snake_case for method name works too.\n\n\nYou can also use conditions, if(..), else(), endif()\n```php\nstr('\u003chtml\u003ehi\u003c/html\u003e')\n            -\u003eifContains('hi')\n            -\u003eupper();\n\u003e\u003e \u003cHTML\u003eHI\u003c/HTML\u003e       \n```\n\n\nif can take an anonymous function\n```php\nstr('\u003chtml\u003ehi\u003c/html\u003e')\n            -\u003eif(function(){\n                    return $this-\u003econtains('hi');\n            })\n            -\u003eupper();\n\u003e\u003e \u003cHTML\u003eHI\u003c/HTML\u003e       \n```\n\nAll methods are availabe to be called statically, as: \n```php\nStrHelper::capitalize('life');\n```\nor using str() function.\n```php\nstr()::capitalize('nomad');\n```\n\n\n__[UTF-8 Support] If mbstring library is installed and you call a strpos function, mb_strpos will be called instead.__\n\n\n## Tests\nSimply use:\n```bash\n$ composer test\n```\n## Credits\n- [Abdulrahman M.](https://github.com/abdumu)\n- [All Contributors](../../contributors)\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawssat%2Fstr-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawssat%2Fstr-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawssat%2Fstr-helper/lists"}