PHP code example of erenkucukersoftware / powerful-php

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

    

erenkucukersoftware / powerful-php example snippets



$snakeCase = strtolower(
    preg_replace('/(.)(?=[A-Z])/u', '$1_', 
        preg_replace('/\s+/u', '', 
            ucwords('HelloWorld')
        )
    )
);
             
var_dump($snakeCase); // "hello_world"

//powerfulphp

$snakeCase = 
    pipe('Hello World')
    ->ucwords(_)
    ->preg_replace('/\s+/u', '', _)
    ->preg_replace('/(.)(?=[A-Z])/u', '$1_', _)
    ->strtolower(_)
    ->var_dump;
//
// string(11) "hello_world"
//

pipe('hello')
    ->str_replace('o', '', _)
    ->var_dump; // "hell"

pipe('some')
    ->is_array
    ->dd; // bool(false) 

$context = pipe('hello')->strtoupper;

var_dump($context);
// object(Fun\Pipe\Pipe)#8 (1) { ... } 

var_dump($context());
// string(5) "HELLO"

pipe()
    ->use('Some\\Namespace')->foo // Call "\Some\Namespace\foo()"
    ->foo // Call "\foo()"
;


pipe()
    ->use('Some\\Namespace', fn($pipe) => 
        $pipe
            ->a // Call "\Some\Namespace\a()"
            ->b // Call "\Some\Namespace\b()"
    )
    ->a // Call "a()"
;