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

Breadcrumb

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

function LSM::remove

Removes a sequence

Parameters

string $sequence Sequence to remove:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Syntax/LSM.php, line 84

Class

LSM
Longest Sequence Matcher. Utility class used by the scanner to consume the longest sequence of character given a set of allowed characters sequences.

Namespace

Peast\Syntax

Code

public function remove($sequence) {
    if ($this->handleEncoding) {
        $s = Utils::stringToUTF8Array($sequence);
        $first = $s[0];
    }
    else {
        $first = $sequence[0];
    }
    if (isset($this->map[$first])) {
        $len = $this->handleEncoding ? count($s) : strlen($sequence);
        $this->map[$first]["map"] = array_diff($this->map[$first]["map"], array(
            $sequence,
        ));
        if (!count($this->map[$first]["map"])) {
            unset($this->map[$first]);
        }
        elseif ($this->map[$first]["maxLen"] === $len) {
            // Recalculate the max length if necessary
            foreach ($this->map[$first]["map"] as $m) {
                $this->map[$first]["maxLen"] = max($this->map[$first]["maxLen"], strlen($m));
            }
        }
    }
    return $this;
}

API Navigation

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