rector/packages/Testing/Fixture/FixtureSplitter.php
Tomas Votruba 184cf49468 Updated Rector to commit f9de5d311e7e69d1ad2cb5f3087970d8b9335920
f9de5d311e [Php80] Handle RenameClassRector+AnnotationToAttributeRector with auto import and existing attribute defined (#5219)
2023-11-02 03:20:18 +00:00

36 lines
988 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Testing\Fixture;
use RectorPrefix202311\Nette\Utils\FileSystem;
/**
* @api
*/
final class FixtureSplitter
{
public static function containsSplit(string $fixtureFileContent) : bool
{
return \strpos($fixtureFileContent, "-----\n") !== \false || \strpos($fixtureFileContent, "-----\r\n") !== \false;
}
/**
* @return array<int, string>
*/
public static function split(string $filePath) : array
{
$fixtureFileContents = FileSystem::read($filePath);
return self::splitFixtureFileContents($fixtureFileContents);
}
/**
* @return array<int, string>
*/
public static function splitFixtureFileContents(string $fixtureFileContents) : array
{
$posixContents = \explode("-----\n", $fixtureFileContents);
if (isset($posixContents[1])) {
return $posixContents;
}
return \explode("-----\r\n", $fixtureFileContents);
}
}