@@ -35,20 +35,25 @@ public static function lineCount( string $filePath ): int {
3535 }
3636
3737
38+
3839 /**
39- * @param string $pathToSourceFile
40- * @param int $linesPerFile
41- * @param string $prefix
40+ * @param string $pathToSourceFile
41+ * @param int $linesPerFile
42+ * @param string|null $prefix
4243 * @param string|null $destinationPath
43- *
44- * @returns array An array of the paths to the split files.
45- * @throws \MichaelDrennen\LocalFile\Exceptions\ CantWriteToReadOnlyDirectory
46- * @throws \MichaelDrennen\LocalFile\Exceptions\ SourceFileDoesNotExist
47- * @throws \MichaelDrennen\LocalFile\Exceptions\UnableToReadFile
48- * @throws \MichaelDrennen\LocalFile\Exceptions\UnableToOpenSplitFileHandle
49- * @throws \MichaelDrennen\LocalFile\Exceptions\ UnableToWriteLineToSplitFile
44+ * @param string $DIRECTORY_SEPARATOR
45+ * @return array An array of the paths to the split files.
46+ * @throws CantWriteToReadOnlyDirectory
47+ * @throws SourceFileDoesNotExist
48+ * @throws UnableToOpenSplitFileHandle
49+ * @throws UnableToReadFile
50+ * @throws UnableToWriteLineToSplitFile
5051 */
51- public static function split ( string $ pathToSourceFile , $ linesPerFile = 1000 , string $ prefix = null , string $ destinationPath = null ): array {
52+ public static function split ( string $ pathToSourceFile ,
53+ $ linesPerFile = 1000 ,
54+ string $ prefix = null ,
55+ string $ destinationPath = null ,
56+ string $ DIRECTORY_SEPARATOR = DIRECTORY_SEPARATOR ): array {
5257
5358 if ( false === file_exists ( $ pathToSourceFile ) ):
5459 throw new SourceFileDoesNotExist ( "Can't split [ " . $ pathToSourceFile . "] because it doesn't exist. " );
@@ -75,8 +80,8 @@ public static function split( string $pathToSourceFile, $linesPerFile = 1000, st
7580 /**
7681 * Make sure there is a trailing DIRECTORY_SEPARATOR
7782 */
78- if ( DIRECTORY_SEPARATOR != substr ( $ destinationPath , -1 ) ):
79- $ destinationPath .= DIRECTORY_SEPARATOR ;
83+ if ( $ DIRECTORY_SEPARATOR != substr ( $ destinationPath , -1 ) ):
84+ $ destinationPath .= $ DIRECTORY_SEPARATOR ;
8085 endif ;
8186
8287 if ( false === is_writeable ( $ destinationPath ) ):
@@ -90,7 +95,6 @@ public static function split( string $pathToSourceFile, $linesPerFile = 1000, st
9095
9196 while ( false !== ( $ line = fgets ( $ sourceHandle ) ) ):
9297
93-
9498 $ line = trim ( $ line );
9599
96100 // process the line read.
0 commit comments