PHP code example of php-rules / rules-filter

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

    

php-rules / rules-filter example snippets


declare(strict_types = 1);

namespace App;

class ContainerRulesArrayMap
{
    private $rules = [];

    private $items = [];

    public function __construct(array $tasks)
    {
        $this->items = $tasks;
    }

    public function addRule(Rule $rule) : void
    {
        $this->rules[] = $rule;
    }

    /**
     * execRule
     *
     * run each rule and aply the filter method
     * to each item from array origin
     *
     *
     * @return void
     */

    public function execRule() : void
    {
        foreach ($this->rules as $rule) {
            $this->items = $rule->map($this->items);
        }
    }