Beispiel #1
0
 function it_has_a_line_break()
 {
     $newLineBreak = "\r\n";
     $this->getLineBreak()->shouldBe(StringUtil::detectLineBreak($this->content));
     $this->setLineBreak($newLineBreak);
     $this->getLineBreak()->shouldBe($newLineBreak);
 }
Beispiel #2
0
 /**
  * Creates a Text instance from a string.
  *
  * @param $string
  *
  * @return static
  */
 public static function fromString($string)
 {
     try {
         $lineBreak = StringUtil::detectLineBreak($string);
     } catch (DifferentLineBreaksFoundException $e) {
         $lineBreak = $e->getNumberLineBreakOther() >= $e->getNumberLineBreakWindows() ? StringUtil::LINE_BREAK_OTHER : StringUtil::LINE_BREAK_WINDOWS;
     }
     return new static(StringUtil::breakIntoLines($string), $lineBreak);
 }
 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);
 }