PHP Classes
elePHPant
Icontem

File: classes/css-parser/css-element.php

Recommend this page to a friend!
  Classes of Gonzalo Chumillas  >  PHP CSS Parser  >  classes/css-parser/css-element.php  >  Download  
File: classes/css-parser/css-element.php
Role: Class source
Content type: text/plain
Description: CSSElement class
Class: PHP CSS Parser
Get HTML document nodes matching a CSS selector
Author: By
Last change: commit
Merge branch 'master' of https://github.com/cequiel/cssparser
update
Date: 2 years ago
Size: 1,179 bytes
 

Contents

Class file image Download
<?php

class CSSElement {
   
/**
     * Tag name.
     * @var string
     */
   
private $tag_name;
   
   
/**
     * List of filters.
     * @var array(CSSFilter, ...)
     */
   
private $filters;
   
   
/**
     * @param string $tag_name
     */
   
public function __construct($tag_name) {
       
$this->filters = array();
       
$this->tag_name = $tag_name;
    }
   
   
/**
     * Gets tag name.
     * @return string
     */
   
public function getTagName() {
        return
$this->tag_name;
    }
   
   
/**
     * Adds a filter.
     * @param CSSFilter $filter
     */
   
public function addFilter($filter) {
       
array_push($this->filters, $filter);
    }
   
   
/**
     * Does the node match?
     * @param DOMElement $node
     * @return boolean
     */
   
public function match($node) {
       
$ret = FALSE;
       
        if (
$this->tag_name == "*" || $node->nodeName == $this->tag_name) {
           
$ret = TRUE;
            foreach (
$this->filters as $filter) {
                if (!
$filter->match($node)) {
                   
$ret = FALSE;
                    break;
                }
            }
        }
        return
$ret;
    }
}