{"id":33018425,"url":"https://github.com/kzykhys/Text","last_synced_at":"2025-11-16T14:00:36.698Z","repository":{"id":9927540,"uuid":"11940389","full_name":"kzykhys/Text","owner":"kzykhys","description":"Text - Simple 1 Class Text Manipulation Library","archived":false,"fork":false,"pushed_at":"2013-08-25T14:28:35.000Z","size":67,"stargazers_count":53,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-20T12:27:35.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kzykhys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-07T03:20:44.000Z","updated_at":"2023-11-11T05:17:12.000Z","dependencies_parsed_at":"2022-09-24T05:10:29.617Z","dependency_job_id":null,"html_url":"https://github.com/kzykhys/Text","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kzykhys/Text","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzykhys%2FText","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzykhys%2FText/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzykhys%2FText/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzykhys%2FText/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kzykhys","download_url":"https://codeload.github.com/kzykhys/Text/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kzykhys%2FText/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284719042,"owners_count":27052182,"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-11-16T02:00:05.974Z","response_time":65,"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":[],"created_at":"2025-11-13T18:00:39.568Z","updated_at":"2025-11-16T14:00:36.693Z","avatar_url":"https://github.com/kzykhys.png","language":"PHP","funding_links":[],"categories":["字符串","Text and Numbers","字符串( Strings )","Strings","字符串 Strings"],"sub_categories":[],"readme":"Text - Simple 1 Class Text Manipulation Library\n-----------------------------------------------\n\n[![Latest Stable Version](https://poser.pugx.org/kzykhys/text/v/stable.png)](https://packagist.org/packages/kzykhys/text)\n[![Build Status](https://travis-ci.org/kzykhys/Text.png?branch=master)](https://travis-ci.org/kzykhys/Text)\n[![Coverage Status](https://coveralls.io/repos/kzykhys/Text/badge.png?branch=master)](https://coveralls.io/r/kzykhys/Text?branch=master)\n\nDo you remember [PHP's string functions][strings]?\nIf not, just wrap you text with `Text`! It will save a minute on your coding.\n\n`Text` is extracted from [kzykhys/Ciconia][ciconia]. this is used for markdown processing.\n\nInstallation\n------------\n\nModify your composer.json and run `php composer.phar update`\n\n``` json\n{\n    \"require\": {\n        \"kzykhys/text\":\"~1.0.0\"\n    }\n}\n```\n\nRequirements\n------------\n\n**PHP5.4+**\n\nGet Started\n-----------\n\n`Text` acts like a string\n\n```\n\u003c?php\n\nuse KzykHys\\Text\\Text;\n\n$text = new Text('Lorem Ipsum');\necho $text;\n\n// Lorem Ipsum\n```\n\n`Text` can also be called statically\n\n```\n\u003c?php\n\nuse KzykHys\\Text\\Text;\n\n$text = Text::create('Lorem Ipsum');\necho $text;\n\n// Lorem Ipsum\n```\n\nManipulation methods are *chainable*:\n\n``` php\n$text = new Text('foo');\n$text\n    -\u003eappend('bar')     // foobar\n    -\u003eprepend('baz')    // bazfoobar\n    -\u003ewrap('-')         // -bazfoobar-\n    -\u003eupper()           // -BAZFOOBAR-\n    -\u003elower()           // -bazfoobar-\n    -\u003etrim('-')         // bazfoobar\n    -\u003ertrim('r')        // bazfooba\n    -\u003eltrim('b')        // azfooba\n;\n```\n\nSpecial note for `replace()`\n\n``` php\n$text = new Text('FooBarBaz');\n$text-\u003ereplace('/Foo(Bar)(Baz)/', function (Text $whole, Text $bar, Text $baz) {\n    return $bar-\u003eupper()-\u003eappend($baz-\u003elower());\n});\necho $text;\n\n// BARbaz\n```\n\nIf the second argument is [callable], callback takes at least one parameter. The whole match being first, and matched subpatterns.\nAll parameters are `Text` instance.\n\n\nAPI\n---\n\n### Manipulation (Chainable)\n\nMethod                           | Description\n---------------------------------|--------------\ncreate($text)                    | Create a new Text instance.\nappend($text)                    | Append the string.\nprepend($text)                   | Prepend the string.\nwrap($start, \\[$end])            | Surround text with given string.\nlower()                          | Make a string lowercase.\nupper()                          | Make a string uppercase.\ntrim(\\[$charList])               | Strip whitespace (or other characters) from the beginning and end of a string.\nrtrim(\\[$charList])              | Strip whitespace (or other characters) from the end of a string.\nltrim(\\[$charList])              | Strip whitespace (or other characters) from the beginning of a string.\nescapeHtml(\\[$option])           | Convert special characters to HTML entities.\nreplace($pattern, $replacement)  | Perform a regular expression search and replace. If $replacement is the callable, a callback that will be called and passed an array of matched elements in the subject string.\nreplaceString($search, $replace) | Replace all occurrences of the search string with the replacement string.\nindent(\\[$spaces])               | Add one level of line-leading spaces.\noutdent(\\[$spaces])              | Remove one level of line-leading tabs or spaces.\ndetab(\\[$spaces])                | Convert tabs to spaces.\neachLine($callback)              | Apply a user function to every line of the string.\n\n### Test\n\nMethod                           | Description\n---------------------------------|--------------\nisEmpty()                        | Determine whether a variable is empty\nisNumeric()                      | Finds whether a variable is a number or a numeric string\nmatch($pattern, \\[\u0026$matches])    | Perform a regular expression match\n\n### Miscellaneous\n\nMethod                           | Description\n---------------------------------|--------------\nsplit($pattern, \\[$flags])       | Split string by a regular expression\nlines(\\[$pattern])               | Split string by a line break\nchars()                          | Convert a string to an array\nlength()                         | Gets the length of a string\ncountLines()                     | Gets the number of lines\nindexOf($needle, \\[$offset])     | Find the position of the first occurrence of a substring in a string\n\n### Filesystem\n\nMethod                           | Description\n---------------------------------|--------------\nsave($path)                      | Write a string to a file\n\nLicense\n-------\n\nThe MIT License\n\nAuthor\n------\n\nKazuyuki Hayashi (@kzykhys)\n\n[ciconia]:  https://github.com/kzykhys/Ciconia\n[strings]:  http://www.php.net/manual/en/ref.strings.php\n[callable]: http://www.php.net/manual/en/language.types.callable.php","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkzykhys%2FText","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkzykhys%2FText","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkzykhys%2FText/lists"}