String

Introduction

The string service in the Streams Platform extends Laravel's Str class.

Basic Usage

To use the string utility first include the \Anomaly\Streams\Platform\Support\Str class.

humanize

The humanize method humanizes slug type strings.

$str = app(\Anomaly\Streams\Platform\Support\Str::class);

$str->humanize('default_table_name_example');
// default table name example

ucwords($str->humanize('default_page'));
// Default Page
{{ str_humanize('default_table_name_example') }}
{# default table name example #}

{{ ucwords(str_humanize('default_page')) }}
{# Default Page #}

truncate

The truncate is identical to Laravel's limit method except that it preserves words.

$str = app(\Anomaly\Streams\Platform\Support\Str::class);

$str->truncate('The CMS built for everyone.', 10); // The CMS...
{{ str_truncate('The CMS built for everyone.', 10) }}
{# The CMS... #}

linkify

The linkify method wraps URLs in link tags.

$str = app(\Anomaly\Streams\Platform\Support\Str::class);

$str->linkify('Checkout http://google.com!'); // Checkout <a href="http://google.com">http://google.com</a>!
{{ str_linkify('Checkout http://google.com!') }}
{# // Checkout <a href="http://google.com">http://google.com</a>! #}

{{ 'Checkout http://google.com!'|str_linkify }}
{# Checkout <a href="http://google.com">http://google.com</a>! #}