Skip to content

Commit

Permalink
Remove Usage of str_concat_space
Browse files Browse the repository at this point in the history
  • Loading branch information
onairmarc committed Nov 6, 2024
1 parent 4e4857b commit 4658930
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class DirectoryNotFoundException extends BaseException
public function __construct(?string $path = null)
{
if (is_null($path)) {
$msg = str_concat_space('Unable to locate directory on line', $this->line, 'in', $this->file);
$msg = "Unable to locate directory on line {$this->line} in {$this->file}";
} else {
$msg = str_concat_space('Unable to locate directory', $path, 'on line', $this->line, 'in', $this->file);
$msg = "Unable to locate directory {$path} on line {$this->line} in {$this->file}";
}

parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious());
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/FilesystemExceptions/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class FileNotFoundException extends BaseException
public function __construct(?string $path = null)
{
if (is_null($path)) {
$msg = str_concat_space('Unable to locate file on line', $this->line, 'in', $this->file);
$msg = "Unable to locate file on line {$this->line} in {$this->file}";
} else {
$msg = str_concat_space('Unable to locate file', $path, 'on line', $this->line, 'in', $this->file);
$msg = "Unable to locate file {$path} on line {$this->line} in {$this->file}";
}

parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious());
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ImproperBooleanReturnedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(bool $expected = true)
$actual = 'true';
}

$msg = str_concat_space('Improper boolean returned. Expected', $expect, 'but got', $actual);
$msg = "Improper boolean returned. Expected {$expect} but got {$actual}";

parent::__construct($msg, ExitCode::DATA_ERROR, $this->getPrevious());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/NotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class NotImplementedException extends BaseException
{
public function __construct()
{
$msg = str_concat_space('Method is not implemented on line', $this->line, 'in', $this->file);
$msg = "Method is not implemented on line {$this->line} in {$this->file}";

parent::__construct($msg, ExitCode::RESOURCE_UNAVAILABLE, $this->getPrevious());
}
Expand Down
3 changes: 2 additions & 1 deletion src/Objects/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static function toShort(array|string $code): array|string
$convertedInnerArray = preg_replace('/\n\s*/', ' ', $convertedInnerArray);

if (!is_string($convertedInnerArray)) {
throw new TypeError(str_concat_space('Expected string, got ', get_type($convertedInnerArray)));
$type = get_type($convertedInnerArray);
throw new TypeError("Expected string, got {$type}");
}

return "[\n " . $convertedInnerArray . "\n]";
Expand Down

0 comments on commit 4658930

Please sign in to comment.