{"id":27185951,"url":"https://github.com/bdusell/jitsu-wrap","last_synced_at":"2025-04-09T17:55:39.102Z","repository":{"id":56999487,"uuid":"42756799","full_name":"bdusell/jitsu-wrap","owner":"bdusell","description":"Object-oriented wrappers for PHP strings, arrays, and regexes","archived":false,"fork":false,"pushed_at":"2016-05-07T08:34:23.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T17:46:21.580Z","etag":null,"topics":["array","method-chaining","oop","php","regex","regular-expression","string","web-development"],"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/bdusell.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":"2015-09-19T02:44:36.000Z","updated_at":"2017-10-17T21:16:49.000Z","dependencies_parsed_at":"2022-08-21T11:40:38.305Z","dependency_job_id":null,"html_url":"https://github.com/bdusell/jitsu-wrap","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdusell","download_url":"https://codeload.github.com/bdusell/jitsu-wrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248083590,"owners_count":21045122,"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":["array","method-chaining","oop","php","regex","regular-expression","string","web-development"],"created_at":"2025-04-09T17:55:33.856Z","updated_at":"2025-04-09T17:55:39.086Z","avatar_url":"https://github.com/bdusell.png","language":"PHP","readme":"jitsu/wrap\n----------\n\nThis package includes object-oriented wrapper classes for PHP strings, arrays,\nand regular expressions (respectively, `Jitsu\\XString`, `Jitsu\\XArray`, and\n`Jitsu\\XRegex`). These classes simply build upon the functions in the packages\n[`jitsu/string`](https://github.com/bdusell/jitsu-string),\n[`jitsu/array`](https://github.com/bdusell/jitsu-array), and\n[`jitsu/regex`](https://github.com/bdusell/jitsu-regex), providing an\nobject-oriented interface to the static methods implemented there. The OOP\nversions automatically unwrap their arguments and wrap their return values.\n\nThis package is part of [Jitsu](https://github.com/bdusell/jitsu).\n\n## Installation\n\nInstall this package with [Composer](https://getcomposer.org/):\n\n```sh\ncomposer require jitsu/wrap\n```\n\n## Namespace\n\nAll classes are defined under the namespace `Jitsu`.\n\n## Usage\n\nHere's a quick example to illustrate this package's tremendous usefulness:\n\n```php\nuse Jitsu\\XArray;\nuse Jitsu\\XString;\n\n// Wisdom from the ancient Romans?\n$s = new XString('Repus Terces Egassem');\n\n// Maybe not...\necho $s-\u003esplit()-\u003emap(function($s) {\n\treturn (new XString($s))-\u003elowerFirst()-\u003ereverse()-\u003ecapitalize();\n})-\u003ejoin(' '), \"\\n\";\n// =\u003e Super Secret Message\n```\n\n## API\n\n### class Jitsu\\\\XString\n\nAn object-oriented wrapper for the `string` type.\n\nSee [jitsu/string](https://github.com/bdusell/jitsu-string).\n\n#### new XString($value = '')\n\n|   | Type |\n|---|------|\n| **`$value`** | `string|self` |\n\n#### $x\\_string-\u003e\\_\\_toString()\n\n#### XString::unwrap($x)\n\n#### $x\\_string-\u003elength()\n\n#### $x\\_string-\u003esize()\n\n#### $x\\_string-\u003eisEmpty()\n\n#### $x\\_string-\u003eequal($that)\n\n#### $x\\_string-\u003eiEqual($that)\n\n#### $x\\_string-\u003echars()\n\n#### $x\\_string-\u003echunks($n)\n\n#### $x\\_string-\u003esplit($delim = null, $limit = null)\n\n#### $x\\_string-\u003etokenize($chars)\n\n#### $x\\_string-\u003ejoin($strs = null)\n\n#### $x\\_string-\u003etrim($chars = null)\n\n#### $x\\_string-\u003ertrim($chars = null)\n\n#### $x\\_string-\u003eltrim($chars = null)\n\n#### $x\\_string-\u003elower()\n\n#### $x\\_string-\u003eupper()\n\n#### $x\\_string-\u003elcfirst()\n\n#### $x\\_string-\u003elowerFirst()\n\n#### $x\\_string-\u003eucfirst()\n\n#### $x\\_string-\u003eupperFirst()\n\n#### $x\\_string-\u003eucwords()\n\n#### $x\\_string-\u003ecapitalize()\n\n#### $x\\_string-\u003ecapitalizeWords()\n\n#### $x\\_string-\u003ereplace($old, $new)\n\n#### $x\\_string-\u003ereplaceAndCount($old, $new)\n\n#### $x\\_string-\u003eiReplace($old, $new)\n\n#### $x\\_string-\u003eiReplaceAndCount($old, $new)\n\n#### $x\\_string-\u003ereplaceMultiple($pairs)\n\n#### $x\\_string-\u003etranslate($old, $new)\n\n#### $x\\_string-\u003esubstring($offset, $length = null)\n\n#### $x\\_string-\u003ereplaceSubstring($new, $offset, $length = null)\n\n#### $x\\_string-\u003eslice($i, $j = null)\n\n#### $x\\_string-\u003ereplaceSlice($new, $i, $j = null)\n\n#### $x\\_string-\u003einsert($new, $offset)\n\n#### $x\\_string-\u003epad($n, $pad = ' ')\n\n#### $x\\_string-\u003elpad($n, $pad = ' ')\n\n#### $x\\_string-\u003erpad($n, $pad = ' ')\n\n#### $x\\_string-\u003ewrap($cols, $sep = \"\\\\n\")\n\n#### $x\\_string-\u003erepeat($n)\n\n#### $x\\_string-\u003ereverse()\n\n#### $x\\_string-\u003estartingWith($substr)\n\n#### $x\\_string-\u003eiStartingWith($substr)\n\n#### $x\\_string-\u003erStartingWith($char)\n\n#### $x\\_string-\u003estartingWithChars($chars)\n\n#### $x\\_string-\u003epreceding($substr)\n\n#### $x\\_string-\u003eiPreceding($substr)\n\n#### $x\\_string-\u003ewords($chars = null)\n\n#### $x\\_string-\u003ewordCount($chars = null)\n\n#### $x\\_string-\u003efindWords($chars = null)\n\n#### $x\\_string-\u003ewordWrap($width, $sep = \"\\\\n\")\n\n#### $x\\_string-\u003ecompare($that)\n\n#### $x\\_string-\u003eiCompare($that)\n\n#### $x\\_string-\u003enCompare($that, $n)\n\n#### $x\\_string-\u003einCompare($that, $n)\n\n#### $x\\_string-\u003elocaleCompare($that)\n\n#### $x\\_string-\u003ehumanCompare($that)\n\n#### $x\\_string-\u003eiHumanCompare($that)\n\n#### $x\\_string-\u003esubstringCompare($that, $offset, $length)\n\n#### $x\\_string-\u003eiSubstringCompare($that, $offset, $length)\n\n#### $x\\_string-\u003econtains($substr, $offset = 0)\n\n#### $x\\_string-\u003eiContains($substr, $offset = 0)\n\n#### $x\\_string-\u003econtainsChars($chars)\n\n#### $x\\_string-\u003econtainsChar($char)\n\n#### $x\\_string-\u003ebeginsWith($prefix)\n\n#### $x\\_string-\u003eiBeginsWith($prefix)\n\n#### $x\\_string-\u003eendsWith($suffix)\n\n#### $x\\_string-\u003eiEndsWith($suffix)\n\n#### $x\\_string-\u003eremovePrefix($prefix)\n\n#### $x\\_string-\u003eiRemovePrefix($prefix)\n\n#### $x\\_string-\u003eremoveSuffix($suffix)\n\n#### $x\\_string-\u003eiRemoveSuffix($suffix)\n\n#### $x\\_string-\u003efind($substr, $offset = 0)\n\n#### $x\\_string-\u003eiFind($substr, $offset = 0)\n\n#### $x\\_string-\u003erFind($substr, $offset = 0)\n\n#### $x\\_string-\u003ebefore($substr)\n\n#### $x\\_string-\u003eafter($substr)\n\n#### $x\\_string-\u003eisLower()\n\n#### $x\\_string-\u003eisUpper()\n\n#### $x\\_string-\u003eisAlphanumeric()\n\n#### $x\\_string-\u003eisAlphabetic()\n\n#### $x\\_string-\u003eisControl()\n\n#### $x\\_string-\u003eisDecimal()\n\n#### $x\\_string-\u003eisHex()\n\n#### $x\\_string-\u003eisVisible()\n\n#### $x\\_string-\u003eisPrintable()\n\n#### $x\\_string-\u003eisPunctuation()\n\n#### $x\\_string-\u003eisWhitespace()\n\n#### $x\\_string-\u003ecount($substr, $offset = 0, $length = null)\n\n#### $x\\_string-\u003echaracterRun($chars, $begin = 0, $end = null)\n\n#### $x\\_string-\u003eescapeCString()\n\n#### $x\\_string-\u003eunescapeCString()\n\n#### $x\\_string-\u003eescapePhpString()\n\n#### $x\\_string-\u003eunescapeBackslashes()\n\n#### $x\\_string-\u003eparseInt($base = null)\n\n#### $x\\_string-\u003eparseReal()\n\n#### $x\\_string-\u003eencodeHex()\n\n#### $x\\_string-\u003edecodeHex()\n\n#### $x\\_string-\u003eencodeBase64()\n\n#### $x\\_string-\u003edecodeBase64()\n\n#### XString::fromAscii($n)\n\n#### XString::chr($n)\n\n#### $x\\_string-\u003etoAscii()\n\n#### $x\\_string-\u003eord()\n\n#### $x\\_string-\u003ebyteCounts()\n\n#### $x\\_string-\u003eunique()\n\n#### $x\\_string-\u003eunusedBytes()\n\n#### $x\\_string-\u003eencodeHtml($noquote = false)\n\n#### $x\\_string-\u003eescapeHtml($noquote = false)\n\n#### $x\\_string-\u003eunencodeHtml()\n\n#### XString::encodeHtmlDict($noquote = false)\n\n#### $x\\_string-\u003eencodeHtmlEntities()\n\n#### XString::encodeHtmlEntitiesDict()\n\n#### $x\\_string-\u003estripTags()\n\n#### $x\\_string-\u003eparseRawQueryString()\n\n#### XString::encodeStandardQueryString($data, $sep = '\u0026')\n\n#### XString::encodeQueryString($data, $sep = '\u0026')\n\n#### $x\\_string-\u003eencodeStandardUrl()\n\n#### $x\\_string-\u003edecodeStandardUrl()\n\n#### $x\\_string-\u003eencodeUrl()\n\n#### $x\\_string-\u003edecodeUrl()\n\n#### $x\\_string-\u003eparseCsv($delim = ',', $quote = '\"', $escape = '\\\\\\\\')\n\n#### $x\\_string-\u003emd5()\n\n#### $x\\_string-\u003emd5Hex()\n\n#### $x\\_string-\u003esha1()\n\n#### $x\\_string-\u003esha1Hex()\n\n#### $x\\_string-\u003erot13()\n\n#### $x\\_string-\u003eshuffle()\n\n#### $x\\_string-\u003eformatMoney()\n\n#### XString::formatNumber($number, $decimals = 0, $decimal\\_point = '.', $thousands\\_sep = ',')\n\n#### $x\\_string-\u003elevenshtein($that, $ins = null, $repl = null, $del = null)\n\n#### $x\\_string-\u003esplitCamelCase()\n\n#### $x\\_string-\u003epluralize()\n\n#### XString::capture($callback)\n\n### class Jitsu\\\\XArray\n\nAn object-oriented wrapper class for the `array` type.\n\nSee [jitsu/array](https://github.com/bdusell/jitsu-array).\n\n#### new XArray($value = array())\n\n|   | Type |\n|---|------|\n| **`$value`** | `array|self` |\n\n#### $x\\_array-\u003e\\_\\_toString()\n\n|   | Type |\n|---|------|\n| returns | `string` |\n\n#### $x\\_array-\u003ecount()\n\n#### $x\\_array-\u003egetIterator()\n\n#### $x\\_array-\u003eoffsetExists($offset)\n\n#### $x\\_array-\u003eoffsetGet($offset)\n\n#### $x\\_array-\u003eoffsetSet($offset, $value)\n\n#### $x\\_array-\u003eoffsetUnset($offset)\n\n#### XArray::unwrap($x)\n\n#### $x\\_array-\u003ejoin($str = '')\n\n#### $x\\_array-\u003esize()\n\n#### $x\\_array-\u003elength()\n\n#### $x\\_array-\u003eisEmpty()\n\n#### $x\\_array-\u003eget($key, $default = null)\n\n#### $x\\_array-\u003egetRef($key, $default = null)\n\n#### $x\\_array-\u003ehasKey($key)\n\n#### XArray::normalizeKey($k)\n\n#### $x\\_array-\u003eremove($key)\n\n#### $x\\_array-\u003ekeys()\n\n#### $x\\_array-\u003evalues()\n\n#### $x\\_array-\u003elistValues($keys, $default = null)\n\n#### $x\\_array-\u003erequireValues($keys)\n\n#### $x\\_array-\u003efirst()\n\n#### $x\\_array-\u003elast()\n\n#### $x\\_array-\u003eappend($value)\n\n#### $x\\_array-\u003eappendMany($values)\n\n#### $x\\_array-\u003econcat($array)\n\n#### $x\\_array-\u003epush($value)\n\n#### $x\\_array-\u003epop()\n\n#### $x\\_array-\u003eshift()\n\n#### $x\\_array-\u003eunshift($value)\n\n#### $x\\_array-\u003ekeyOf($value)\n\n#### $x\\_array-\u003eindexOf($value)\n\n#### $x\\_array-\u003ekeysOf($value)\n\n#### $x\\_array-\u003econtains($value)\n\n#### $x\\_array-\u003eat($i)\n\n#### $x\\_array-\u003epairAt($i)\n\n#### $x\\_array-\u003ekeyAt($i)\n\n#### $x\\_array-\u003eslice($i, $j = null)\n\n#### $x\\_array-\u003epairSlice($i, $j = null)\n\n#### $x\\_array-\u003eassignSlice($sub, $i, $j = null)\n\n#### $x\\_array-\u003eremoveSlice($i, $j = null)\n\n#### $x\\_array-\u003ereverse()\n\n#### $x\\_array-\u003ereversePairs()\n\n#### XArray::range($i, $j = null, $step = 1)\n\n#### XArray::fromPairs($pairs)\n\n#### XArray::fromLists($keys, $values)\n\n#### $x\\_array-\u003etoSet($value = true)\n\n#### XArray::fill($value, $n)\n\n#### $x\\_array-\u003epad($value, $n)\n\n#### $x\\_array-\u003epluck($key)\n\n#### $x\\_array-\u003epick($keys)\n\n#### $x\\_array-\u003egetPick($keys, $default = null)\n\n#### $x\\_array-\u003einvert()\n\n#### $x\\_array-\u003eextend($array)\n\n#### $x\\_array-\u003edeepExtend($array)\n\n#### $x\\_array-\u003echunks($n)\n\n#### $x\\_array-\u003emap($callback)\n\n#### $x\\_array-\u003efilter($callback = null)\n\n#### $x\\_array-\u003efilterPairs($callback)\n\n#### $x\\_array-\u003esum()\n\n#### $x\\_array-\u003eproduct()\n\n#### $x\\_array-\u003ereduce($callback, $initial = null)\n\n#### $x\\_array-\u003eapply($callback)\n\n#### $x\\_array-\u003etraverseLeaves($callback)\n\n#### $x\\_array-\u003edifference($array, $key\\_cmp = null, $value\\_cmp = true)\n\n#### $x\\_array-\u003epairDifference($array, $key\\_cmp = null, $value\\_cmp = null)\n\n#### $x\\_array-\u003ekeyDifference($array, $key\\_cmp = null)\n\n#### $x\\_array-\u003evalueDifference($array, $value\\_cmp = null)\n\n#### $x\\_array-\u003epairIntersection($array, $key\\_cmp = null, $value\\_cmp = null)\n\n#### $x\\_array-\u003ekeyIntersection($array, $key\\_cmp = null)\n\n#### $x\\_array-\u003evalueIntersection($array, $value\\_cmp = null)\n\n#### $x\\_array-\u003euniqueValues()\n\n#### $x\\_array-\u003ehasOnlyKeys($keys, \u0026$unexpected = null)\n\n#### $x\\_array-\u003ehasKeys($keys, \u0026$missing = null)\n\n#### $x\\_array-\u003ehasExactKeys($keys, \u0026$unexpected = null, \u0026$missing = null)\n\n#### $x\\_array-\u003erandomKey()\n\n#### $x\\_array-\u003erandomValue()\n\n#### $x\\_array-\u003erandomPair()\n\n#### $x\\_array-\u003erandomKeys($n)\n\n#### $x\\_array-\u003eshuffle()\n\n#### $x\\_array-\u003esort($value\\_cmp = null)\n\n#### $x\\_array-\u003ereverseSort()\n\n#### $x\\_array-\u003elocaleSort()\n\n#### $x\\_array-\u003esortPairs($value\\_cmp = null)\n\n#### $x\\_array-\u003ereverseSortPairs()\n\n#### $x\\_array-\u003esortKeys($key\\_cmp = null)\n\n#### $x\\_array-\u003ereverseSortKeys()\n\n#### $x\\_array-\u003ehumanSortValues()\n\n#### $x\\_array-\u003eiHumanSortValues()\n\n#### $x\\_array-\u003elowerKeys()\n\n#### $x\\_array-\u003eupperKeys()\n\n#### $x\\_array-\u003eisSequential()\n\n#### $x\\_array-\u003eisAssociative()\n\n#### $x\\_array-\u003elooksSequential()\n\n#### $x\\_array-\u003elooksAssociative()\n\n#### $x\\_array-\u003ecountValues()\n\n### class Jitsu\\\\XRegex\n\nAn object-oriented wrapper for PHP's PCRE patterns.\n\nSee [jitsu/regex](https://github.com/bdusell/jitsu-regex).\n\n#### new XRegex($arg, $flags = '', $start = null, $end = null)\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$arg`** | `string|\\Jitsu\\XString|self` | Either a PCRE pattern or another `XRegex`. |\n| **`$flags`** | `string|\\Jitsu\\XString` | PCRE flags such as `i`, etc. |\n| **`$start`** | `string|\\Jitsu\\XString|null` | Optional starting delimiter for the escaped PCRE pattern stored in `pattern`. This might simplify the escaped pattern if, for example, it is known that the regular expression contains a lot of slashes. |\n| **`$start`** | `string|\\Jitsu\\XString|null` | Optional ending delimiter. Only necessary for bracket pairs. |\n\n#### $x\\_regex-\u003e\\_\\_toString()\n\n#### $x\\_regex-\u003ematch($str, $offset = 0)\n\n#### $x\\_regex-\u003ematchWithOffsets($str, $offset = 0)\n\n#### $x\\_regex-\u003ematchAll($str, $offset = 0)\n\n#### $x\\_regex-\u003ematchAllWithOffsets($str, $offset = 0)\n\n#### XRegex::escape($str, $delim = null)\n\n#### $x\\_regex-\u003ereplace($str, $replacement, $limit = null)\n\n#### $x\\_regex-\u003ereplaceAndCount($str, $replacement, $limit = null)\n\n#### $x\\_regex-\u003ereplaceWith($str, $callback, $limit = null)\n\n#### $x\\_regex-\u003ereplaceAndCountWith($str, $callback, $limit = null)\n\n#### $x\\_regex-\u003ereplaceAndFilter($str, $replacement, $limit = null)\n\n#### $x\\_regex-\u003ereplaceAndFilterAndCount($str, $replacement, $limit = null)\n\n#### $x\\_regex-\u003egrep($strs)\n\n#### $x\\_regex-\u003einvertedGrep($strs)\n\n#### $x\\_regex-\u003esplit($str, $limit = null)\n\n#### $x\\_regex-\u003esplitWithOffsets($str, $limit = null)\n\n#### $x\\_regex-\u003esplitAndFilter($str, $limit = null)\n\n#### $x\\_regex-\u003esplitAndFilterWithOffsets($str, $limit = null)\n\n#### $x\\_regex-\u003einclusiveSplit($str, $limit = null)\n\n#### $x\\_regex-\u003einclusiveSplitWithOffsets($str, $limit = null)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fjitsu-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdusell%2Fjitsu-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fjitsu-wrap/lists"}