PHP code example of vendeka-nl / text

1. Go to this page and download the library: Download vendeka-nl/text library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vendeka-nl / text example snippets


use Vendeka\Text\Text;

Text::boot();

use Illuminate\Support\Str;

Str::of('taco')->enclose('[', ']')->upper(); //=> '[TACO]'
Str::unclose('/gift/', '/'); //=> 'gift'

Str::enclose('directory', '/'); //=> '/directory/'
Str::enclose('directory/', '/'); //=> '/directory/'
Str::enclose('Paragraph', '<p>', '</p>'); //=> '<p>Paragraph</p>'
Str::enclose('<p>Paragraph</p>', '<p>', '</p>'); //=> '<p>Paragraph</p>'

Str::exclamation('yelling'); //=> 'Yelling!'
Str::exclamation('Why are you yelling?'); //=> 'Why are you yelling?!'

Str::glue('/', 'https://example.com/', '/dashboard'); //=> 'https://example.com/dashboard'
Str::glue('/', '/var', '/www/', []); //=> '/var/www/'

Str::natural('my-first-blog'); //=> 'My first blog'
Str::natural('i_love_kebab'); // => 'I love kebab'

Str::normalizeWhitespace(" White\r\n  space "); //=> 'White space'

Str::nullIfBlank(' '); //=> null

Str::nullIfEmpty(''); //=> null

Str::question('Questions'); //=> 'Questions?'

Str::sentence('this is a sentence'); //=> 'This is a sentence.'

Str::toParagraphs("Paragraph 1\n\nParagraph 2"); // => instance of Vendeka\Text\Paragraphs

use Vendeka\Text\Words;

(string) Str::toWords('a-dog'); //=> 'a dog'
Str::of('aSnake')->toWords()->of()->lower(); //=> 'a snake'
(string) (new Words(['From', 'an', 'array'])); //=> 'From an array'

Str::unclose('<p>Gift</p>', '<p>', '</p>'); //=> 'Gift'
Str::unclose('/present/', '/') //=> 'present'

Str::unprefix('#yolo', '#') //=> 'yolo'

Str::unsuffix('/var/www/', '/') //=> '/var/www'

$paragraphs = new Paragraphs("First paragraph\n\nSecond paragraph...");
$paragraphs = new Paragraphs(['First paragraph', 'Second paragraph...']);
$paragraphs = Str::toParagraphs("First paragraph\n\nSecond paragraph...");

$words = new Words("First Second");
$words = new Words(['First', 'Second']);
$words = Str::toWords("First Second");

Str::toWords('my-slug')->toString(); // => 'my slug'
Str::toWords('my-folder')->toString('/'); // => 'my/slug'
(string) Str::toWords("It's a kind of magic!"); // => "It's a kind of magic!"