HTMLPurifier_AttrDef_Enum::make PHP Method

make() public method

public make ( string $string ) : HTMLPurifier_AttrDef_Enum
$string string In form of comma-delimited list of case-insensitive valid values. Example: "foo,bar,baz". Prepend "s:" to make case sensitive
return HTMLPurifier_AttrDef_Enum
    public function make($string)
    {
        if (strlen($string) > 2 && $string[0] == 's' && $string[1] == ':') {
            $string = substr($string, 2);
            $sensitive = true;
        } else {
            $sensitive = false;
        }
        $values = explode(',', $string);
        return new HTMLPurifier_AttrDef_Enum($values, $sensitive);
    }

Usage Example

Exemplo n.º 1
0
 function test_make()
 {
     $factory = new HTMLPurifier_AttrDef_Enum();
     $def = $factory->make('foo,bar');
     $def2 = new HTMLPurifier_AttrDef_Enum(array('foo', 'bar'));
     $this->assertIdentical($def, $def2);
     $def = $factory->make('s:foo,BAR');
     $def2 = new HTMLPurifier_AttrDef_Enum(array('foo', 'BAR'), true);
     $this->assertIdentical($def, $def2);
 }
HTMLPurifier_AttrDef_Enum