Skip to content

Commit

Permalink
Fixed Pslam errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Feb 3, 2025
1 parent 581c908 commit b59abea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/Attachment/Engines/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Str;
use Orchid\Attachment\Contracts\Engine;
use Orchid\Attachment\MimeTypes;
use RuntimeException;

class Generator implements Engine
{
Expand Down Expand Up @@ -107,7 +108,16 @@ public function setPath(?string $path = null): static
*/
public function hash(): string
{
return sha1_file($this->file->path());
$hash = sha1_file($this->file->path());

if ($hash === false) {
throw new RuntimeException(sprintf(
'Failed to generate a hash for the file: %s.',
$this->file->path()
));
}

return $hash;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Attachment/Models/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function getRelativeUrlAttribute(): ?string
return null;
}

return parse_url($url, PHP_URL_PATH);
return parse_url($url, PHP_URL_PATH) ?: null;
}

public function getTitleAttribute(): ?string
Expand Down

0 comments on commit b59abea

Please sign in to comment.