/**
  * Check if the media rule should be included
  *
  * @param  \Crossjoin\Css\Format\Rule\AtMedia\MediaQuery  $media_query
  * @return bool
  */
 protected function isAllowedMediaRule(MediaQuery $media_query)
 {
     $type = $media_query->getType();
     $condition = count($media_query->getConditions());
     return ($type === MediaQuery::TYPE_ALL || $type === MediaQuery::TYPE_SCREEN) && $condition === 0;
 }
Exemple #2
0
 /**
  * Extracts the type from the query part of the media rule and returns a MediaQuery instance for it.
  *
  * @param $queryString
  * @return MediaQuery|null
  */
 protected function getQueryInstanceFromQueryString($queryString)
 {
     if (preg_match('/^[ \\r\\n\\t\\f]*(?:(only[ \\r\\n\\t\\f]+)|(not[ \\r\\n\\t\\f]+))?([^ \\r\\n\\t\\f]*)[ \\r\\n\\t\\f]*(?:(?:and)?[ \\r\\n\\t\\f]*)*$/iD', $queryString, $matches)) {
         $type = $matches[3] === "" ? MediaQuery::TYPE_ALL : $matches[3];
         $query = new MediaQuery($type);
         if (!empty($matches[1])) {
             $query->setIsOnly(true);
         }
         if (!empty($matches[2])) {
             $query->setIsNot(true);
         }
         return $query;
     }
     return null;
 }