Download the PHP package omaressaouaf/text-morph without Composer
On this page you can find all versions of the php package omaressaouaf/text-morph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download omaressaouaf/text-morph
More information about omaressaouaf/text-morph
Files in omaressaouaf/text-morph
Package text-morph
Short Description A lightweight PHP package for reversible text transformations using simple morphing algorithms and a composable pipeline
License MIT
Homepage https://github.com/omaressaouaf/text-morph
Informations about the package text-morph
TextMorph
A lightweight PHP package for reversible text transformations using simple morphing algorithms and a composable pipeline.
Features
- Rotational morphing: shift letters across a 52-character alphabet with wrap-around
- Substitution morphing: bidirectional character-pair swaps with case preservation
- Transposition morphing: rail-fence (zigzag) character reordering
- Composite pipeline: chain multiple morphers and reverse them in one call
- Every morpher supports
morph()andunmorph() - Framework-agnostic, zero runtime dependencies
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.
Installation
Install via Composer:
Usage
Every morpher implements the TextMorpher contract:
Rotational Morphing
Shift each letter forward across a-zA-Z, wrapping from Z back to a. Non-alphabetic characters are left unchanged.
More examples:
Substitution Morphing
Swap character pairs bidirectionally. Each pair defines a two-way substitution that preserves letter case.
Because pairs are swaps, unmorph() applies the same transform as morph():
Transposition Morphing
Reorder characters using a rail-fence (zigzag) cipher. Letters are written in a zigzag across the configured number of rails, then read row by row.
unmorph() splits the text back into rails and reads the zigzag to restore the original order.
Composite Pipeline
Chain multiple morphers together. morph() applies them in registration order; unmorph() reverses them.
Custom Morphers
The package is fully extensible. You can create your own morphers by implementing the TextMorpher contract.
Example
Then use it on its own or inside a composite pipeline:
This approach allows you to implement completely custom transformations while preserving the same architecture and developer experience as the package's built-in morphers.
Testing
Run unit tests:
License
This package is licensed under the MIT License.