Download the PHP package phlak/twine without Composer
On this page you can find all versions of the php package phlak/twine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package twine
String manipulation, leveled up! -- by, Chris Kankiewicz (@phlak.dev)
Introduction
Twine is a string manipulation library with an expressive, fluent syntax.
Requirements
- PHP >= 8.1
- The Multibyte String extension
- The OpenSSL extension
Install with Composer
Getting Started
First, import Twine:
Then instantiate a Twine object by newing up a Twine\Str
object and passing
your string as the first parameter.
You may also instantiate a Twine\Str
object statically via the make()
method.
Or use the global str()
helper method. The method takes a string as the only
parameter and returns a Twine\Str
object.
Once you have a concrete Twine\Str
instance you may treat it like any other
string. This includes echoing it or using any of PHP's built-in string functions
against it.
The strength of Twine, however comes from its built-in methods.
At this point you're ready to start using Twine by calling any of its many built-in methods.
Available Methods
after • append • base64 • base64Decode • base64Encode • bcrypt • before • camelCase • characters • chunk • contains • count • crc32 • crypt • decrypt • echo • encoding • encrypt • endsWith • equals • explode • first • format • from • hex • hexEncode • hexDecode • insensitiveMatch • insert • in • isAlphabetic • isAlphanumeric • isEmpty • isLowercase • isNotEmpty • isNumeric • isPrintable • isPunctuation • isUppercase • isWhitespace • join • kebabCase • last • length • lowercase • lowercaseFirst • lowercaseWords • match • matchAll • matches • md5 • nth • pad • padBoth • padLeft • padRight • pascalCase • prepend • repeat • replace • reverse • sha1 • sha256 • shuffle • similarity • snakeCase • split • startsWith • strip • studlyCase • substring • to • trim • trimLeft • trimRight • truncate • uppercase • uppercaseFirst • uppercaseWords • url • words • wrap • wrapHard • wrapSoft
Method Chaining
A Twine string can be manipulated fluently by chaining methods. Here are a few example chains:
Perform a substring comparison:
Encode a file in compliance with RFC 2045.
Additional details available in the full documentation at https://twine.phlak.net.
MultiByte Strings
Twine aims for multibyte string compatibility by relying on PHP's Multibyte String extension (mbstring) to perform string operations. For this reason, the mbstring extension is required. Multibyte strings include Unicode encodings such as UTF-8 and UCS-2.
Changelog
A list of changes can be found on the GitHub Releases page.
Troubleshooting
For general help and support join our GitHub Discussion or reach out on Bluesky.
Please report bugs to the GitHub Issue Tracker.
Copyright
This project is licensed under the MIT License.
All versions of twine with dependencies
ext-mbstring Version *
ext-openssl Version *