Kedrigern\phpIO\Files::call PHP Method

call() public method

public call ( callable $function, null | callable $post = null, null | array &$log = null ) : Files
$function callable apply to the files
$post null | callable function called after process all files
$log null | array array of callback results (event post callback)
return Files $this
    public function call($function, $post = null, &$log = null)
    {
        $results = array();
        chdir($this->dir);
        if (is_callable($function)) {
            foreach ($this->files as $key => $file) {
                if (is_file($file)) {
                    $results[$key] = call_user_func($function, $file);
                }
            }
        }
        if (is_callable($post)) {
            $results['post'] = call_user_func($post, $results);
        }
        $log = $results;
        chdir($this->originDir);
        return $this;
    }