Source

trekel / src / php / Trekel / Node / Attribute / EndsWith.php

<?php

class Trekel_Node_Attribute_EndsWith extends Trekel_Node_Attribute {

  public function reduce ($node, $idx, $total) {
    $this->initMatches();
    $data = $this->getData($node);
    $value = $this->getValue();

    $expectedPos = strlen($data) - strlen($value);

    if (strpos($data, $value) === $expectedPos) {
      $this->matchNode($node);
    }

    return $this->getMatches();
  }

}// end Trekel_Node_Attribute_EndsWith