palmtree/string

Object-oriented string manipulation library

v1.0.2 2023-09-26 11:31 UTC

This package is auto-updated.

Last update: 2024-11-26 14:03:28 UTC


README

License Build Packagist Version

Object-oriented string manipulation library

Requirements

  • PHP >= 8.1

Installation

Use composer to add the package to your dependencies:

composer require palmtree/string

Usage

use function Palmtree\String\s;

$str = s('foo bar baz');

$str->startsWith('foo'); // true
$str->endsWith('baz'); // true
$str->contains('bar'); // true

$str->replace('bar', 'qux'); // 'foo qux baz'

$str->after('bar'); // ' baz'
$str->afterLast('b'); // 'az'
$str->beforeFirst('b'); // 'foo '

$str->kebab(); // 'foo-bar-baz'
$str->camel(); // 'fooBarBaz'
$str->snake(); // 'foo_bar_baz'

Many other methods are provided. Read through the documented source code to see more.

License

Released under the MIT license