---
title: String
---

# String

<div class="documentation__toc"></div>

## Introduction

The `string` service in the Streams Platform extends Laravel's [Str](https://laravel.com/docs/helpers#strings) 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.

```php
$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
```

```twig
{{ 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**.

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

$str->truncate('The CMS built for everyone.', 10); // The CMS...
```

```twig
{{ str_truncate('The CMS built for everyone.', 10) }}
{# The CMS... #}
```

### linkify

The `linkify` method wraps URLs in link tags.

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

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

```twig
{{ 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>! #}
```
