PHP code example of wtframework / types

1. Go to this page and download the library: Download wtframework/types 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/ */

    

wtframework / types example snippets


use function WTFramework\Types\arr;
use function WTFramework\Types\num;
use function WTFramework\Types\str;

str('reverse me')
->explode(' ')  // returns arr(['reverse', 'me'])
->reverse()
->implode(' '); // returns str('me reverse')

str('example')
->len(); // returns 7

str('example')
->len(return: $length); // returns $this

// $length = 7

str('eXaMpLe')
->toupper()
->extract($uppercase)
->tolower()
->extract($lowercase);

// $uppercase = str('EXAMPLE');
// $lowercase = str('example');

str('example')
->echo(
  prefix: 'this is an ',
  suffix: '.'
);

// this is an example.

arr([1, 2, 3])->contains(1); // returns true
arr([1, 2, 3])->advance(); // advances the internal pointer

use WTFramework\Types\Arr;
use WTFramework\Types\Num;
use WTFramework\Types\Str;

Str::httpbuildquery($data);
Str::unserialize($data);

Arr::fill($start_index, $count, $value);
Arr::range($start, $end);

Num::max(...$values);
Num::min(...$values);
Num::pi();

str('example')->return(); // returns 'example'
arr([1, 2, 3])(); // returns [1, 2, 3]

use WTFramework\Types\Str;

Str::macro('camelCase', function ()
{

  return $this->ucwords()
  ->replace(' ', '')
  ->lcfirst();

});

// Returns 'camelCase'
str('camel case')->camelCase()();