function let(Text $text)
 {
     $rootPath = __DIR__ . '/../../../../..';
     $filename = sprintf(self::FILENAME, $rootPath);
     $lines = file($filename, FILE_IGNORE_NEW_LINES);
     $text->getLines()->willReturn($lines);
 }
 /** {@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 let(TextSanitizer $textSanitizer, LocationSanitizer $locationSanitizer, Text $text)
 {
     $this->rootPath = __DIR__ . '/../../../../../';
     $filename = sprintf(self::ORIGINAL_FILENAME, $this->rootPath);
     $lines = file($filename, FILE_IGNORE_NEW_LINES);
     $text->getLines()->willReturn($lines);
     $this->beConstructedWith($textSanitizer, $locationSanitizer);
 }
 /**
  * @param Text $text
  *
  * @return array
  */
 public function from(Text $text)
 {
     $lines = $text->getLines();
     $lineBreak = $text->getLineBreak();
     $content = implode($lineBreak, $lines);
     $rawTokens = token_get_all($content);
     return $this->tokenBuilder->buildFromRaw($rawTokens);
 }
 function it_converts_file_content_into_php_tokens(TokenBuilder $tokenBuilder, Text $text)
 {
     $rootPath = __DIR__ . '/../../../../../';
     $filename = sprintf(self::FILENAME, $rootPath);
     $content = file_get_contents($filename);
     $lineBreak = StringUtil::detectLineBreak($content);
     $lines = explode($lineBreak, $content);
     $rawTokens = token_get_all($content);
     $text->getLineBreak()->willReturn($lineBreak);
     $text->getLines()->willReturn($lines);
     $tokenBuilder->buildFromRaw($rawTokens)->willReturn(array());
     $this->from($text);
 }
示例#6
0
 /**
  * @param Text $text
  *
  * @return string
  */
 public function make(Text $text)
 {
     return implode($text->getLineBreak(), $text->getLines());
 }