Exemplo n.º 1
0
 /**
  * @see File_Archive_Predicate::isTrue()
  */
 function isTrue(&$source)
 {
     $sourceMIME = $source->getMIME();
     foreach ($this->mimes as $mime) {
         if (MIME_Type::isWildcard($mime)) {
             $result = MIME_Type::wildcardMatch($mime, $sourceMIME);
         } else {
             $result = $mime == $sourceMIME;
         }
         if ($result !== false) {
             return $result;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Perform a wildcard match on a MIME type
  *
  * Example:
  * MIME_Type::wildcardMatch('image/*', 'image/png')
  *
  * @param  string  $card Wildcard to check against
  * @param  string  $type MIME type to check
  * @return boolean true if there was a match, false otherwise
  */
 function wildcardMatch($card, $type)
 {
     if (!MIME_Type::isWildcard($card)) {
         return false;
     }
     if ($card == '*/*') {
         return true;
     }
     if (MIME_Type::getMedia($card) == MIME_Type::getMedia($type)) {
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  *
  */
 public function testIsWildcard()
 {
     $this->assertTrue(MIME_Type::isWildcard('*/*'));
     $this->assertTrue(MIME_Type::isWildcard('image/*'));
     $this->assertFalse(MIME_Type::isWildcard('text/plain'));
 }