{"id":51189204,"url":"https://github.com/omaressaouaf/text-morph","last_synced_at":"2026-07-02T18:01:20.023Z","repository":{"id":367611077,"uuid":"1281556074","full_name":"omaressaouaf/text-morph","owner":"omaressaouaf","description":"A lightweight PHP package for reversible text transformations using simple morphing algorithms and a composable pipeline","archived":false,"fork":false,"pushed_at":"2026-06-26T17:49:04.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-26T19:18:17.740Z","etag":null,"topics":["algorithms","encoding","encoding-algorithms","encoding-decoding","php","text-morph","text-transformation"],"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/omaressaouaf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-26T17:14:51.000Z","updated_at":"2026-06-26T17:49:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/omaressaouaf/text-morph","commit_stats":null,"previous_names":["omaressaouaf/text-morph"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/omaressaouaf/text-morph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaressaouaf%2Ftext-morph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaressaouaf%2Ftext-morph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaressaouaf%2Ftext-morph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaressaouaf%2Ftext-morph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaressaouaf","download_url":"https://codeload.github.com/omaressaouaf/text-morph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaressaouaf%2Ftext-morph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34855826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"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":["algorithms","encoding","encoding-algorithms","encoding-decoding","php","text-morph","text-transformation"],"created_at":"2026-06-27T13:30:20.041Z","updated_at":"2026-06-27T13:30:22.607Z","avatar_url":"https://github.com/omaressaouaf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TextMorph\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/omaressaouaf/text-morph.svg)](https://packagist.org/packages/omaressaouaf/text-morph)\n[![License](https://img.shields.io/github/license/omaressaouaf/text-morph)](LICENSE)\n[![Tests](https://github.com/omaressaouaf/text-morph/actions/workflows/tests.yml/badge.svg)](https://github.com/omaressaouaf/text-morph/actions/workflows/tests.yml)\n\nA lightweight PHP package for **reversible text transformations** using simple morphing algorithms and a composable pipeline.\n\n## Features\n\n- **Rotational** morphing: shift letters across a 52-character alphabet with wrap-around\n- **Substitution** morphing: bidirectional character-pair swaps with case preservation\n- **Transposition** morphing: rail-fence (zigzag) character reordering\n- **Composite** pipeline: chain multiple morphers and reverse them in one call\n- Every morpher supports `morph()` and `unmorph()`\n- Framework-agnostic, zero runtime dependencies\n\n\u003e TextMorph is a text transformation package. It is not intended for encryption, password hashing, or security-sensitive data. It currently operates on ASCII strings. Multibyte/Unicode-aware transformations are not currently supported.\n\n---\n\n## Installation\n\nInstall via Composer:\n\n```sh\ncomposer require omaressaouaf/text-morph\n```\n\n---\n\n## Usage\n\nEvery morpher implements the `TextMorpher` contract:\n\n```php\nuse Omaressaouaf\\TextMorph\\Contracts\\TextMorpher;\n\ninterface TextMorpher\n{\n    public function morph(string $text): string;\n\n    public function unmorph(string $text): string;\n}\n```\n\n### Rotational Morphing\n\nShift each letter forward across `a-zA-Z`, wrapping from `Z` back to `a`. Non-alphabetic characters are left unchanged.\n\n```php\nuse Omaressaouaf\\TextMorph\\Morphers\\RotationalTextMorpher;\n\n$morpher = new RotationalTextMorpher(3);\n\n$morphed = $morpher-\u003emorph('Meet at 9pm!');\n// Phhw dw 9sp!\n\n$original = $morpher-\u003eunmorph($morphed);\n// Meet at 9pm!\n```\n\nMore examples:\n\n```php\n$morpher = new RotationalTextMorpher(1);\n\n$morpher-\u003emorph('a'); // b\n$morpher-\u003emorph('z'); // B\n$morpher-\u003emorph('Z'); // a\n```\n\n### Substitution Morphing\n\nSwap character pairs bidirectionally. Each pair defines a two-way substitution that preserves letter case.\n\n```php\nuse Omaressaouaf\\TextMorph\\Morphers\\SubstitutionTextMorpher;\n\n$morpher = new SubstitutionTextMorpher(['ab', 'cd']);\n\n$morpher-\u003emorph('aabbcc'); // bbaacc\n$morpher-\u003emorph('adam');   // bcbm\n```\n\nBecause pairs are swaps, `unmorph()` applies the same transform as `morph()`:\n\n```php\n$morpher-\u003eunmorph('bbaacc'); // aabbcc\n```\n\n### Transposition Morphing\n\nReorder characters using a rail-fence (zigzag) cipher. Letters are written in a zigzag across the configured number of rails, then read row by row.\n\n```php\nuse Omaressaouaf\\TextMorph\\Morphers\\TranspositionTextMorpher;\n\n$morpher = new TranspositionTextMorpher(3);\n\n$morpher-\u003emorph('HELLO');       // HOELL\n$morpher-\u003emorph('Meet at 9pm!'); // M 9eta p!etm\n```\n\n`unmorph()` splits the text back into rails and reads the zigzag to restore the original order.\n\n### Composite Pipeline\n\nChain multiple morphers together. `morph()` applies them in registration order; `unmorph()` reverses them.\n\n```php\nuse Omaressaouaf\\TextMorph\\Morphers\\CompositeTextMorpher;\nuse Omaressaouaf\\TextMorph\\Morphers\\RotationalTextMorpher;\nuse Omaressaouaf\\TextMorph\\Morphers\\SubstitutionTextMorpher;\nuse Omaressaouaf\\TextMorph\\Morphers\\TranspositionTextMorpher;\n\n$pipeline = new CompositeTextMorpher();\n\n$pipeline-\u003eadd(new SubstitutionTextMorpher(['ae', 'io']));\n$pipeline-\u003eadd(new RotationalTextMorpher(5));\n$pipeline-\u003eadd(new TranspositionTextMorpher(3));\n\n$original = 'Meet at 9pm!';\n\n$morphed = $pipeline-\u003emorph($original);\n$restored = $pipeline-\u003eunmorph($morphed);\n\n// $restored === $original\n```\n\n---\n\n### Custom Morphers\n\nThe package is fully extensible. You can create your own morphers by implementing the `TextMorpher` contract.\n\n#### Example\n\n```php\nnamespace App\\Morphers;\n\nuse Omaressaouaf\\TextMorph\\Contracts\\TextMorpher;\n\nclass ReverseTextMorpher implements TextMorpher\n{\n    public function morph(string $text): string\n    {\n        return strrev($text);\n    }\n\n    public function unmorph(string $text): string\n    {\n        return strrev($text);\n    }\n}\n```\n\nThen use it on its own or inside a composite pipeline:\n\n```php\nuse App\\Morphers\\ReverseTextMorpher;\nuse Omaressaouaf\\TextMorph\\Morphers\\CompositeTextMorpher;\nuse Omaressaouaf\\TextMorph\\Morphers\\RotationalTextMorpher;\n\n$pipeline = new CompositeTextMorpher();\n$pipeline-\u003eadd(new ReverseTextMorpher());\n$pipeline-\u003eadd(new RotationalTextMorpher(13));\n\n$morphed = $pipeline-\u003emorph('Hello');\n$original = $pipeline-\u003eunmorph($morphed);\n```\n\nThis approach allows you to implement completely custom transformations while preserving the same architecture and developer experience as the package's built-in morphers.\n\n---\n\n## Testing\n\nRun unit tests:\n\n```sh\ncomposer test\n```\n\n---\n\n## License\n\nThis package is licensed under the [MIT License](https://github.com/omaressaouaf/text-morph/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaressaouaf%2Ftext-morph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaressaouaf%2Ftext-morph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaressaouaf%2Ftext-morph/lists"}