/** {@inheritdoc} */ public function findBelow(Text $text, $pattern, $location = null) { $location = (null !== $location ? $location : $text->getCurrentLineNumber()) + 1; $lines = $text->getLines(); $belowLines = array_slice($lines, $location, null, true); return $this->findIn($belowLines, $pattern); }
function it_finds_relatively_to_the_first_line(Text $text) { $pattern = '/\\[Sniggering\\]/'; $lineNumber = 5; $text->getCurrentLineNumber()->shouldNotBeCalled(); $this->findAbove($text, $pattern, 0)->shouldBe(false); $this->findBelow($text, $pattern, 0)->shouldBe($lineNumber); }
/** {@inheritdoc} */ public function findBelow(Text $text, $pattern, $location = null) { trigger_error(__CLASS__ . ' has been replaced by Text#setCurrentLineNumber', \E_USER_DEPRECATED); $foundLineNumber = (null !== $location ? $location : $text->getCurrentLineNumber()) + $pattern; if (0 > $foundLineNumber || $foundLineNumber >= $text->getLength()) { return false; } return $foundLineNumber; }
/** {@inheritdoc} */ public function findBelow(Text $text, $pattern, $location = null) { trigger_error(__CLASS__ . ' is no longer supported and will be removed in version 2', \E_USER_DEPRECATED); $location = (null !== $location ? $location : $text->getCurrentLineNumber()) + 1; $tokens = $this->converter->from($text); $total = count($tokens); for ($index = 0; $index < $total; $index++) { $token = $tokens[$index]; if ($token->getLineNumber() === $location) { break; } } return $this->findIn($tokens, $index, $pattern); }
function let(TextSanitizer $textSanitizer, Text $text) { $text->getCurrentLineNumber()->willReturn(self::LINE_NUMBER); $text->getLength()->willReturn(50); $this->beConstructedWith($textSanitizer); }