You are here

class FunctionNode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/css-selector/Node/FunctionNode.php \Symfony\Component\CssSelector\Node\FunctionNode

Represents a "<selector>:<name>(<arguments>)" node.

This component is a port of the Python cssselect library, which is copyright Ian Bicking, @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>

Hierarchy

Expanded class hierarchy of FunctionNode

See also

https://github.com/SimonSapin/cssselect.

5 files declare their use of FunctionNode
FunctionExtension.php in vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php
FunctionNodeTest.php in vendor/symfony/css-selector/Tests/Node/FunctionNodeTest.php
HtmlExtension.php in vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php
ParserTest.php in vendor/symfony/css-selector/Tests/Parser/ParserTest.php
Translator.php in vendor/symfony/css-selector/XPath/Translator.php

File

vendor/symfony/css-selector/Node/FunctionNode.php, line 24

Namespace

Symfony\Component\CssSelector\Node
View source
class FunctionNode extends AbstractNode {

  /**
   * @var NodeInterface
   */
  private $selector;

  /**
   * @var string
   */
  private $name;

  /**
   * @var Token[]
   */
  private $arguments;

  /**
   * @param NodeInterface $selector
   * @param string        $name
   * @param Token[]       $arguments
   */
  public function __construct(NodeInterface $selector, $name, array $arguments = array()) {
    $this->selector = $selector;
    $this->name = strtolower($name);
    $this->arguments = $arguments;
  }

  /**
   * @return NodeInterface
   */
  public function getSelector() {
    return $this->selector;
  }

  /**
   * @return string
   */
  public function getName() {
    return $this->name;
  }

  /**
   * @return Token[]
   */
  public function getArguments() {
    return $this->arguments;
  }

  /**
   * {@inheritdoc}
   */
  public function getSpecificity() {
    return $this->selector
      ->getSpecificity()
      ->plus(new Specificity(0, 1, 0));
  }

  /**
   * {@inheritdoc}
   */
  public function __toString() {
    $arguments = implode(', ', array_map(function (Token $token) {
      return "'" . $token
        ->getValue() . "'";
    }, $this->arguments));
    return sprintf('%s[%s:%s(%s)]', $this
      ->getNodeName(), $this->selector, $this->name, $arguments ? '[' . $arguments . ']' : '');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractNode::$nodeName private property
AbstractNode::getNodeName public function Overrides NodeInterface::getNodeName
FunctionNode::$arguments private property
FunctionNode::$name private property
FunctionNode::$selector private property
FunctionNode::getArguments public function
FunctionNode::getName public function
FunctionNode::getSelector public function
FunctionNode::getSpecificity public function Returns node's specificity. Overrides NodeInterface::getSpecificity
FunctionNode::__construct public function
FunctionNode::__toString public function Returns node's string representation. Overrides NodeInterface::__toString