PhpSandbox\PHPSandbox::whitelist PHP Méthode

whitelist() public méthode

You can pass an associative array of whitelist types and their names, or a string $type and array of $names, or pass a string of the $type and $name
public whitelist ( string | array $type, string | array | null $name = null )
$type string | array Associative array or string of whitelist type to set
$name string | array | null Array or string of whitelist name to set
    public function whitelist($type, $name = null)
    {
        if (is_array($type)) {
            foreach ($type as $_type => $name) {
                if (is_string($name) && $name && isset($this->whitelist[$_type])) {
                    $this->whitelist[$_type][$name] = true;
                } else {
                    if (isset($this->whitelist[$_type]) && is_array($name)) {
                        foreach ($name as $_name) {
                            if (is_string($_name) && $_name) {
                                $this->whitelist[$_type][$_name] = true;
                            }
                        }
                    }
                }
            }
        } else {
            if (isset($this->whitelist[$type]) && is_array($name)) {
                foreach ($name as $_name) {
                    if (is_string($_name) && $_name) {
                        $this->whitelist[$type][$_name] = true;
                    }
                }
            } else {
                if (is_string($name) && $name && isset($this->whitelist[$type])) {
                    $this->whitelist[$type][$name] = true;
                }
            }
        }
        return $this;
    }
PHPSandbox