rector/packages/Testing/Fixture/FixtureSplitter.php
Tomas Votruba 671f50c702 Updated Rector to commit ee715396945596fffb158ff8278749feb01ea01a
ee71539694 [NodeTypeResolver] Use isScalar()->yes() usage on StaticTypeAnalyzer and ScalarTypeComparator services (#5099)
2023-10-01 01:36:35 +00:00

36 lines
988 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Testing\Fixture;
use RectorPrefix202310\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);
}
}