Skip to content

Commit e28e648

Browse files
committed
Replace EOL character with PHP_EOL const.
Update whitespace trim logic.
1 parent a81aa19 commit e28e648

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Commands/CrawlRoutes.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public function __construct(Router $router)
5858
{
5959
parent::__construct();
6060

61+
// todo:: replace helper methods
62+
6163
$this->router = $router;
6264
$this->routes = $router->getRoutes();
6365
$this->fileName = config('restricted.file_path') ?: public_path("reserved.txt");
6466
}
6567

66-
67-
6868
/**
6969
* Execute the console command.
7070
*
@@ -105,14 +105,15 @@ function store($routes){
105105
$fileName = $this->fileName;
106106

107107
if(config('restricted.merge') && file_exists($fileName)){
108-
$old = collect(explode("\r\n", file_get_contents($fileName)))
108+
$old = collect(explode(PHP_EOL, file_get_contents($fileName)))
109109
->map(function($value){
110-
return preg_replace("/\s/", '', $value);
110+
return trim($value);
111111
})->all();
112112
$routes = $routes->merge($old);
113113
}
114114

115-
$input = $routes->unique()->sort()->implode("\r\n");
115+
$input = $routes->unique()->sort()->implode(PHP_EOL);
116+
116117
$file = fopen($fileName, 'w+');
117118
fwrite($file, $input);
118119
fclose($file);

0 commit comments

Comments
 (0)