{"id":17061797,"url":"https://github.com/phlak/twine","last_synced_at":"2025-05-14T14:10:09.559Z","repository":{"id":45199316,"uuid":"95623990","full_name":"PHLAK/Twine","owner":"PHLAK","description":"String manipulation, leveled up!","archived":false,"fork":false,"pushed_at":"2025-03-01T00:02:05.000Z","size":1097,"stargazers_count":496,"open_issues_count":1,"forks_count":24,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-13T21:33:49.063Z","etag":null,"topics":["multi-byte-string","multibyte-strings","php","php-library","string-comparison","string-manipulation","strings"],"latest_commit_sha":null,"homepage":"https://twine.phlak.net","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/PHLAK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"PHLAK","custom":"https://paypal.me/ChrisKankiewicz"}},"created_at":"2017-06-28T03:15:12.000Z","updated_at":"2025-04-10T17:43:59.000Z","dependencies_parsed_at":"2025-01-26T07:00:31.574Z","dependency_job_id":"4a525203-2ace-4f07-9c32-e45c2deb637f","html_url":"https://github.com/PHLAK/Twine","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FTwine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FTwine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FTwine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHLAK%2FTwine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHLAK","download_url":"https://codeload.github.com/PHLAK/Twine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160559,"owners_count":22024571,"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":["multi-byte-string","multibyte-strings","php","php-library","string-comparison","string-manipulation","strings"],"created_at":"2024-10-14T10:48:13.032Z","updated_at":"2025-05-14T14:10:04.548Z","avatar_url":"https://github.com/PHLAK.png","language":"PHP","funding_links":["https://github.com/sponsors/PHLAK","https://paypal.me/ChrisKankiewicz"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"twine.png\" alt=\"Twine\" width=\"50%\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  String manipulation, leveled up! -- by, \u003ca href=\"https://www.ChrisKankiewicz.com\"\u003eChris Kankiewicz\u003c/a\u003e (\u003ca href=\"https://bsky.app/profile/phlak.dev\"\u003e@phlak.dev\u003c/a\u003e)\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/PHLAK/Twine/discussions\"\u003e\u003cimg src=\"https://img.shields.io/badge/Join_the-Community-7b16ff.svg?style=for-the-badge\" alt=\"Join the Community\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/users/PHLAK/sponsorship\"\u003e\u003cimg src=\"https://img.shields.io/badge/Become_a-Sponsor-cc4195.svg?style=for-the-badge\" alt=\"Become a Sponsor\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://paypal.me/ChrisKankiewicz\"\u003e\u003cimg src=\"https://img.shields.io/badge/Make_a-Donation-006bb6.svg?style=for-the-badge\" alt=\"One-time Donation\"\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/Twine\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/phlak/twine.svg?style=flat-square\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/Twine\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/phlak/twine.svg?style=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/PHLAK/Twine\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/phlak/twine.svg?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/PHLAK/Twine/actions\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/PHLAK/Twine/test-suite.yaml?style=flat-square\" alt=\"Test Suite\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nIntroduction\n------------\n\nTwine is a string manipulation library with an expressive, fluent syntax.\n\nRequirements\n------------\n\n  - [PHP](https://php.net) \u003e= 8.1\n    - The [Multibyte String](https://www.php.net/manual/en/book.mbstring.php) extension\n    - The [OpenSSL](https://www.php.net/manual/en/book.openssl.php) extension\n\nInstall with Composer\n---------------------\n\n```bash\ncomposer require phlak/twine\n```\n\nGetting Started\n----------------\n\nFirst, import Twine:\n\n```php\nuse PHLAK\\Twine;\n```\n\nThen instantiate a Twine object by newing up a `Twine\\Str` object and passing\nyour string as the first parameter.\n\n```php\n$string = new Twine\\Str('john pinkerton');\n```\n\nYou may also instantiate a `Twine\\Str` object statically via the `make()` method.\n\n```php\n$string = Twine\\Str::make('john pinkerton');\n```\n\nOr use the global `str()` helper method. The method takes a string as the only\nparameter and returns a `Twine\\Str` object.\n\n```php\n$string = str('john pinkerton');\n```\n\nOnce you have a concrete `Twine\\Str` instance you may treat it like any other\nstring. This includes echoing it or using any of PHP's built-in string functions\nagainst it.\n\n```php\necho $string; // Echos 'john pinkerton'\n\nstr_shuffle($string) // Returns something like 'enoipo ktnjhnr'\n\nstrlen($string); // Returns 14\n```\n\nThe strength of Twine, however comes from its built-in methods.\n\n```php\n$string-\u003eecho(); // Echos 'john pinkerton'\n$string-\u003eshuffle(); // Returns something like 'enoipo ktnjhnr'\n$string-\u003elength(); // Returns 14\n\n// or some more interesting methods\n\n$string-\u003ereverse(); // Returns 'notreknip nhoj'\n$string-\u003econtains('pink'); // Returns true\n$string-\u003ereplace('pink', 'purple'); // Returns 'john purpleton'\n$string-\u003esnakeCase(); // Returns 'john_pinkerton'\n```\n\nAt this point you're ready to start using Twine by calling any of its many\nbuilt-in methods.\n\nAvailable Methods\n-----------------\n\n[after](https://twine.phlak.net/docs/methods/after) •\n[append](https://twine.phlak.net/docs/methods/append) •\n[base64](https://twine.phlak.net/docs/methods/base64) •\n[base64Decode](https://twine.phlak.net/docs/methods/base64decode) •\n[base64Encode](https://twine.phlak.net/docs/methods/base64encode) •\n[bcrypt](https://twine.phlak.net/docs/methods/bcrypt) •\n[before](https://twine.phlak.net/docs/methods/before) •\n[camelCase](https://twine.phlak.net/docs/methods/camelcase) •\n[characters](https://twine.phlak.net/docs/methods/characters) •\n[chunk](https://twine.phlak.net/docs/methods/chunk) •\n[contains](https://twine.phlak.net/docs/methods/contains) •\n[count](https://twine.phlak.net/docs/methods/count) •\n[crc32](https://twine.phlak.net/docs/methods/crc32) •\n[crypt](https://twine.phlak.net/docs/methods/crypt) •\n[decrypt](https://twine.phlak.net/docs/methods/decrypt) •\n[echo](https://twine.phlak.net/docs/methods/echo) •\n[encoding](https://twine.phlak.net/docs/methods/encoding) •\n[encrypt](https://twine.phlak.net/docs/methods/encrypt) •\n[endsWith](https://twine.phlak.net/docs/methods/endswith) •\n[equals](https://twine.phlak.net/docs/methods/equals) •\n[explode](https://twine.phlak.net/docs/methods/explode) •\n[first](https://twine.phlak.net/docs/methods/first) •\n[format](https://twine.phlak.net/docs/methods/format) •\n[from](https://twine.phlak.net/docs/methods/from) •\n[hex](https://twine.phlak.net/docs/methods/hex) •\n[hexEncode](https://twine.phlak.net/docs/methods/hexencode) •\n[hexDecode](https://twine.phlak.net/docs/methods/hexdecode) •\n[insensitiveMatch](https://twine.phlak.net/docs/methods/insensitivematch) •\n[insert](https://twine.phlak.net/docs/methods/insert) •\n[in](https://twine.phlak.net/docs/methods/in) •\n[isAlphabetic](https://twine.phlak.net/docs/methods/isalphabetic) •\n[isAlphanumeric](https://twine.phlak.net/docs/methods/isalphanumeric) •\n[isEmpty](https://twine.phlak.net/docs/methods/isempty) •\n[isLowercase](https://twine.phlak.net/docs/methods/islowercase) •\n[isNotEmpty](https://twine.phlak.net/docs/methods/isnotempty) •\n[isNumeric](https://twine.phlak.net/docs/methods/isnumeric) •\n[isPrintable](https://twine.phlak.net/docs/methods/isprintable) •\n[isPunctuation](https://twine.phlak.net/docs/methods/ispunctuation) •\n[isUppercase](https://twine.phlak.net/docs/methods/isuppercase) •\n[isWhitespace](https://twine.phlak.net/docs/methods/iswhitespace) •\n[join](https://twine.phlak.net/docs/methods/join) •\n[kebabCase](https://twine.phlak.net/docs/methods/kebabcase) •\n[last](https://twine.phlak.net/docs/methods/last) •\n[length](https://twine.phlak.net/docs/methods/length) •\n[lowercase](https://twine.phlak.net/docs/methods/lowercase) •\n[lowercaseFirst](https://twine.phlak.net/docs/methods/lowercasefirst) •\n[lowercaseWords](https://twine.phlak.net/docs/methods/lowercasewords) •\n[match](https://twine.phlak.net/docs/methods/match) •\n[matchAll](https://twine.phlak.net/docs/methods/matchall) •\n[matches](https://twine.phlak.net/docs/methods/matches) •\n[md5](https://twine.phlak.net/docs/methods/md5) •\n[nth](https://twine.phlak.net/docs/methods/nth) •\n[pad](https://twine.phlak.net/docs/methods/pad) •\n[padBoth](https://twine.phlak.net/docs/methods/padboth) •\n[padLeft](https://twine.phlak.net/docs/methods/padleft) •\n[padRight](https://twine.phlak.net/docs/methods/padright) •\n[pascalCase](https://twine.phlak.net/docs/methods/pascalcase) •\n[prepend](https://twine.phlak.net/docs/methods/prepend) •\n[repeat](https://twine.phlak.net/docs/methods/repeat) •\n[replace](https://twine.phlak.net/docs/methods/replace) •\n[reverse](https://twine.phlak.net/docs/methods/reverse) •\n[sha1](https://twine.phlak.net/docs/methods/sha1) •\n[sha256](https://twine.phlak.net/docs/methods/sha256) •\n[shuffle](https://twine.phlak.net/docs/methods/shuffle) •\n[similarity](https://twine.phlak.net/docs/methods/similarity) •\n[snakeCase](https://twine.phlak.net/docs/methods/snakecase) •\n[split](https://twine.phlak.net/docs/methods/split) •\n[startsWith](https://twine.phlak.net/docs/methods/startswith) •\n[strip](https://twine.phlak.net/docs/methods/strip) •\n[studlyCase](https://twine.phlak.net/docs/methods/studlycase) •\n[substring](https://twine.phlak.net/docs/methods/substring) •\n[to](https://twine.phlak.net/docs/methods/to) •\n[trim](https://twine.phlak.net/docs/methods/trim) •\n[trimLeft](https://twine.phlak.net/docs/methods/trimleft) •\n[trimRight](https://twine.phlak.net/docs/methods/trimright) •\n[truncate](https://twine.phlak.net/docs/methods/truncate) •\n[uppercase](https://twine.phlak.net/docs/methods/uppercase) •\n[uppercaseFirst](https://twine.phlak.net/docs/methods/uppercasefirst) •\n[uppercaseWords](https://twine.phlak.net/docs/methods/uppercasewords) •\n[url](https://twine.phlak.net/docs/methods/url) •\n[words](https://twine.phlak.net/docs/methods/words) •\n[wrap](https://twine.phlak.net/docs/methods/wrap) •\n[wrapHard](https://twine.phlak.net/docs/methods/wraphard) •\n[wrapSoft](https://twine.phlak.net/docs/methods/wrapsoft)\n\n---\n\nMethod Chaining\n---------------\n\nA Twine string can be manipulated fluently by chaining methods. Here are a few\nexample chains:\n\nPerform a substring comparison:\n\n```php\n$string = new Twine\\Str('john pinkerton');\n\n$string-\u003esubstring(5, 4)-\u003eequals('pink'); // Returns true\n```\n\nEncode a file in compliance with [RFC 2045](https://tools.ietf.org/html/rfc2045).\n\n```php\n$string = new Twine\\Str(file_get_contents('garbage.bin'));\n\n$string-\u003ebase64()-\u003ewrap(76, \"\\r\\n\", Twine\\Config\\Wrap::HARD);\n```\n\nAdditional details available in the full documentation at \u003chttps://twine.phlak.net\u003e.\n\nMultiByte Strings\n-----------------\n\nTwine aims for multibyte string compatibility by relying on PHP's\n[Multibyte String extension](https://www.php.net/manual/en/book.mbstring.php)\n(mbstring) to perform string operations. For this reason, the mbstring extension\nis required. Multibyte strings include Unicode encodings such as UTF-8 and UCS-2.\n\nChangelog\n---------\n\nA list of changes can be found on the [GitHub Releases](https://github.com/PHLAK/Twine/releases) page.\n\nTroubleshooting\n---------------\n\nFor general help and support join our [GitHub Discussion](https://github.com/PHLAK/Twine/discussions) or reach out on [Bluesky](https://bsky.app/profile/phlak.dev).\n\nPlease report bugs to the [GitHub Issue Tracker](https://github.com/PHLAK/Twine/issues).\n\nCopyright\n---------\n\nThis project is licensed under the [MIT License](https://github.com/PHLAK/Twine/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Ftwine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlak%2Ftwine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlak%2Ftwine/lists"}