Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PseudoSimple.php

class PseudoSimple

Selector part simple pseudo class

@author Marco Marchiò <marco.mm89@gmail.com>

Hierarchy

  • class \Peast\Selector\Node\Part\Part
    • class \Peast\Selector\Node\Part\Pseudo extends \Peast\Selector\Node\Part\Part
      • class \Peast\Selector\Node\Part\PseudoSimple extends \Peast\Selector\Node\Part\Pseudo

Expanded class hierarchy of PseudoSimple

File

vendor/mck89/peast/lib/Peast/Selector/Node/Part/PseudoSimple.php, line 24

Namespace

Peast\Selector\Node\Part
View source
class PseudoSimple extends Pseudo {
    
    /**
     * Priority
     *
     * @var int
     */
    protected $priority = 3;
    
    /**
     * Returns true if the selector part matches the given node,
     * false otherwise
     *
     * @param Node $node    Node
     * @param Node $parent  Parent node
     *
     * @return bool
     */
    public function check(Node $node, $parent = null) {
        switch ($this->name) {
            case "pattern":
                return $node instanceof Pattern;
            case "statement":
                return $node instanceof Statement;
            case "expression":
                return $node instanceof Expression;
            case "declaration":
                return $node instanceof Declaration;
            case "last-child":
            case "first-child":
                $first = $this->name === "first-child";
                $props = Utils::getExpandedNodeProperties($parent);
                return count($props) > 0 && ($first ? $props[0] === $node : array_pop($props) === $node);
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Part::getPriority public function
Pseudo::$name protected property Selector name
Pseudo::setName public function Sets the name
PseudoSimple::$priority protected property Priority Overrides Part::$priority
PseudoSimple::check public function Returns true if the selector part matches the given node,
false otherwise
Overrides Part::check

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal