WordPress at a glance
class is not described

Symfony\Component\CssSelector\Parser

Reader{} WC 1.0

CSS selector reader.

This component is a port of the Python cssselect library, which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.

No Hooks.

Return

null. Nothing.

Usage

$Reader = new Reader();
// use class methods

Methods

  1. __construct($source)
  2. ERROR: no method name found on line ` */`
  3. ERROR: no method name found on line ``
  4. ERROR: no method name found on line ``
  5. ERROR: no method name found on line ``
  6. findPattern($pattern)
  7. ERROR: no method name found on line ` return false === $position ? false : $position - $this->position;`
  8. getOffset($string)
  9. getPosition()
  10. getRemainingLength()
  11. getSubstring($length, $offset = 0)
  12. moveToEnd()
  13. ERROR: no method name found on line ``
  14. isEOF()
  15. ERROR: no method name found on line ``
  16. moveForward($length)
  17. ERROR: no method name found on line ``
  18. ERROR: no method name found on line ``

Code of Reader{} WC 5.2.2

<?php
class Reader
{
    /**
     * @var string
     */
    private $source;

    /**
     * @var int
     */
    private $length;

    /**
     * @var int
     */
    private $position = 0;

    /**
     * @param string $source
     */
    public function __construct($source)
    {
        $this->source = $source;
        $this->length = strlen($source);
    }

    /**
     * @return bool
     */
    public function isEOF()
    {
        return $this->position >= $this->length;
    }

    /**
     * @return int
     */
    public function getPosition()
    {
        return $this->position;
    }

    /**
     * @return int
     */
    public function getRemainingLength()
    {
        return $this->length - $this->position;
    }

    /**
     * @param int $length
     * @param int $offset
     *
     * @return string
     */
    public function getSubstring($length, $offset = 0)
    {
        return substr($this->source, $this->position + $offset, $length);
    }

    /**
     * @param string $string
     *
     * @return int
     */
    public function getOffset($string)
    {
        $position = strpos($this->source, $string, $this->position);

        return false === $position ? false : $position - $this->position;
    }

    /**
     * @param string $pattern
     *
     * @return array|false
     */
    public function findPattern($pattern)
    {
        $source = substr($this->source, $this->position);

        if (preg_match($pattern, $source, $matches)) {
            return $matches;
        }

        return false;
    }

    /**
     * @param int $length
     */
    public function moveForward($length)
    {
        $this->position += $length;
    }

    public function moveToEnd()
    {
        $this->position = $this->length;
    }
}