Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecorche committed Nov 22, 2024
1 parent 8af85f0 commit 69ba061
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function __construct(string $pathDir, string $filename, array $options =
// Test folder
$realPath = realpath($pathDir);
if (false === $realPath || !is_writable($realPath)) {
throw new \Exception(sprintf('Folder %s does not exist or is not writable', $pathDir));
throw new \Exception(\sprintf('Folder %s does not exist or is not writable', $pathDir));
}

$this->pathDir = $realPath;
Expand Down Expand Up @@ -168,7 +168,7 @@ public function __construct(string $pathDir, string $filename, array $options =
protected function open(): void
{
if (\is_resource($this->handle)) {
throw new \Exception(sprintf('The file %s is already open', $this->filename));
throw new \Exception(\sprintf('The file %s is already open', $this->filename));
}
++$this->fileNumber;
$this->lines = 0;
Expand All @@ -179,11 +179,11 @@ protected function open(): void
$this->currentPathname = $this->pathDir.'/'.$filename.'.csv';
$this->handle = fopen($this->currentPathname, 'wb'); // Binary is forced. EOL = "\n"
if (false === $this->handle) {
throw new \Exception(sprintf('Error during the opening of the %s file', $this->filename));
throw new \Exception(\sprintf('Error during the opening of the %s file', $this->filename));
}
if ($this->addUtf8Bom) {
if (false === fwrite($this->handle, \chr(0xEF).\chr(0xBB).\chr(0xBF))) {
throw new \Exception(sprintf('Error during the UTF8-BOM writing in %s file', $this->filename));
throw new \Exception(\sprintf('Error during the UTF8-BOM writing in %s file', $this->filename));
}
}
if (null !== $this->header && \count($this->header) > 0) {
Expand All @@ -204,13 +204,13 @@ public function close(): void

if ($this->unixToDos) { // PHP < 8.1
if (\PHP_OS_FAMILY === 'Linux') {
$command = sprintf('%s %s 2> /dev/null', $this->unixToDosPath, $this->currentPathname);
$command = \sprintf('%s %s 2> /dev/null', $this->unixToDosPath, $this->currentPathname);
} else {
$command = sprintf('%s %s', $this->unixToDosPath, $this->currentPathname);
$command = \sprintf('%s %s', $this->unixToDosPath, $this->currentPathname);
}
exec($command, $output, $returnVar);
if (0 !== $returnVar) {
throw new \Exception(sprintf('Unix2dos error (%s file)', $this->filename));
throw new \Exception(\sprintf('Unix2dos error (%s file)', $this->filename));
}
}
}
Expand All @@ -233,7 +233,7 @@ protected function newFile(): void
public function write($data): void
{
if (!\is_resource($this->handle)) {
throw new \Exception(sprintf('Handle does not exist. File %s', $this->filename));
throw new \Exception(\sprintf('Handle does not exist. File %s', $this->filename));
}

// New file
Expand All @@ -250,7 +250,7 @@ public function write($data): void
$result = fputcsv($this->handle, $data, $this->delimiter, $this->enclosure, $this->escape);
}
if (false === $result) {
throw new \Exception(sprintf('Error during the writing in %s file', $this->filename));
throw new \Exception(\sprintf('Error during the writing in %s file', $this->filename));
}

++$this->lines;
Expand Down

0 comments on commit 69ba061

Please sign in to comment.