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

Breadcrumb

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

function PseudoSimple::check

Returns true if the selector part matches the given node, false otherwise

Parameters

Node $node Node:

Node $parent Parent node:

Return value

bool

Overrides Part::check

File

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

Class

PseudoSimple
Selector part simple pseudo class

Namespace

Peast\Selector\Node\Part

Code

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);
    }
}
RSS feed
Powered by Drupal