Mecha CMS

Deep learning on using the API.

Class To

Author: Taufik Nurrohman · 104 Views

Tweet

Convert from X to Y.

Anemon 

To::anemon($input);

Convert encoded JSON, PHP object or array into PHP array:

$test_1 = To::anemon('{"foo":"bar"}');
$test_2 = To::anemon(['foo' => 'bar']);
$test_3 = To::anemon((object) ['foo' => 'bar']);

Base64 

To::base64($input);

Encode string to Base64:

$test = To::base64('i love you');

Camel 

To::camel($input);

Convert string input into camelCase:

$test = To::camel('foo bar baz');

Decimal 

To::dec($input, $z = false, $f = ['&#', ';']);

Convert string into their HTML decimal characters representation:

$test = To::dec('I ❤ U');

File 

To::file($input);

Sanitize string input into safe file path:

$test = To::file('foo / bar / baz .txt / abc $ def $ ghi .txt');

Folder 

To::folder($input);

Sanitize string input into safe folder path:

$test = To::folder('foo / bar / baz .txt / abc $ def $ ghi .txt');

Hexagonal 

To::hex($input, $z = false, $f = ['&#x', ';']);

Convert string into their HTML hexagonal characters representation:

$test = To::hex('I ❤ U');

HTML 

To::html($input);

Decode HTML special characters:

$test = To::html('<foo bar="baz">');

JSON 

To::json($input);

Convert PHP array/object into JSON:

$test = To::json(['foo' => 'bar']);

Key 

To::key($input, $low = true);

Convert string input into a valid array key:

$test_1 = To::key('foo bar baz');
$test_2 = To::key('foo-bar-baz');
$test_3 = To::key('123 foo bar baz');
$test_4 = To::key('123-foo-bar-baz');

Pascal 

To::pascal($input);

Convert string input into PascalCase:

$test = To::pascal('foo bar baz');

Path 

To::path($input);

Convert public URL into private file path:

$test = To::path('http://mecha-cms.com/path/to/file.html');

Sentence 

To::sentence($input, $tail = '.');

Convert string input into Sentence case.:

$test = To::sentence('foo bar baz', '?');

Slug 

To::slug($x, $s = '-', $X = "");

Convert string input into slug-case:

$test = To::slug('foo bar baz');

Related: Functions

Snake 

To::snake($input);

Convert string input into snake_case:

$test_1 = To::snake('123 foo bar baz');
$test_2 = To::key('123 foo bar baz');

Snippet 

To::snippet($input, $html = true, $x = [200, '…']);

Convert string input into snippet text:

$test = To::snippet('foo bar baz qux');

Text 

To::text($x, $c = [], $n = false);

Convert file name or HTML string into plain text:

$test_1 = To::text('foo-bar-baz');
$test_2 = To::text('<p><strong>Foo</strong> Bar <em>Baz</em></p>');

Related: Functions

Title 

To::title($input);

Convert file name, HTML string or plain text into Title Case:

$test_1 = To::title('foo-bar-baz');
$test_2 = To::title('<p><strong>foo</strong> bar <em>baz</em></p>');
$test_3 = To::title('foo bar baz');

URL 

To::url($input, $raw = false);

Convert private file path into public URL, or decode URL special characters:

$test_1 = To::url('.\path\to\file.html');
$test_2 = To::url('foo%20bar+baz');
$test_3 = To::url('foo%20bar+baz', true);

YAML 

To::yaml($input, $c = [], $in = '  ', $safe = false, $dent = 0);

Convert array into YAML string:

$test = To::yaml(['foo' => 'bar']);

0 Comments

No comments yet.