PHP code example of carlosv2 / communism

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

    

carlosv2 / communism example snippets


$value = From($object)->property;
// or
$value = From($object)->extract('property');

To($object)->property = $value;
// or
To($object)->inject('property', $value);

// The `replace` method is avilable for both `From` and `To`
From($object)->property(function ($value) {
    // `$value` will contain the current value for that property
    
    // Whatever is returned will be the new value of the property
    return $newValue;
});
// or
From($object)->replace('property', function ($value) {
    // `$value` will contain the current value for that property
    
    // Whatever is returned will be the new value of the property
    return $newValue;
});