PHP code example of proteins / filter

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

    

proteins / filter example snippets


use Proteins\Filter;

use Proteins\Filters;

class MyClass {
    use Filters;
}

Filter::add('title',function($title){
   return strtoupper($title);
});

// Concatenate effects :
Filter::add('title',function($title){
   return strtoupper($title);
});

Filter::add('title',function($title){
   return $title . '!';
});

Filter::add(['href','src'], function($link){
   return BASE_URL . $link;
});

>Filter::add('href', function($link){
>   return BASE_URL . $link;
>});
>
>Filter::add('src', function($link){
>   return BASE_URL . $link;
>});
>

Filter::add([
   'src' => function($src){
     return BASE_URL . $src;
    },
   'href' => function($href){
     return HTTPS . $href;
    },
]);

>Filter::add('href', function($href){
>   return HTTPS . $href;
>});
>
>Filter::add('src', function($src){
>   return BASE_URL . $src;
>});
>

$the_filter = function($title){
   return strtoupper($title);
};

Filter::add('title',$the_filter);

...

Filter::remove('title',$the_filter);

Filter::remove('title');

Filter::with('title','This was a triumph')

Filter::add('title',function($title){
   return strtoupper($title);
});

Filter::add('title',function($title){
   return $title . '!';
});

echo Filter::with('title','This was a triumph');

// THIS WAS A TRIUMPH!

Filter::with(["document.title", "title"],'This was a triumph')

Filter::add("title", "strtoupper");
echo Filter::with(["document.title", "title"],'This was a triumph');

Filter::add("title", "strtoupper");
Filter::add("document.title", "str_rot13");
echo Filter::with(["document.title", "title"],'This was a triumph');