/** * Parse a MIME type parameter and set object fields * * @param string $param MIME type parameter to parse * @return void */ function parse($param) { $comment = ''; $param = MIME_Type::stripComments($param, $comment); $this->name = $this->getAttribute($param); $this->value = $this->getValue($param); $this->comment = $comment; }
/** * Get a MIME type's subtype * * @param string $type MIME type to get subtype of * * @return string $type's subtype, null if invalid mime type * @static */ function getSubType($type) { $tmp = explode('/', $type); if (!isset($tmp[1])) { return null; } $tmp = explode(';', $tmp[1]); return strtolower(trim(MIME_Type::stripComments($tmp[0], $null))); }
/** * */ public function testStripComments() { $this->assertEquals('def', MIME_Type::stripComments('(abc)def(ghi)', $null)); $this->assertEquals('def', MIME_Type::stripComments('(abc)def', $null)); $this->assertEquals('def', MIME_Type::stripComments('def(ghi)', $null)); $this->assertEquals('def', MIME_Type::stripComments('(\\)abc)def(\\))', $null)); $this->assertEquals('def', MIME_Type::stripComments('(a"bc)def")def', $null)); $this->assertEquals('(abc)def', MIME_Type::stripComments('"(abc)def"', $null)); $comment = ''; $this->assertEquals('def', MIME_Type::stripComments('(abc)def(ghi)', $comment)); $this->assertEquals('abc ghi', $comment); }
public function testStripCommentsParameterComment() { $comment = ''; $this->assertEquals('def', MIME_Type::stripComments('(abc)def(ghi)', $comment)); $this->assertEquals('abc ghi', $comment); }