Skip to content

Commit

Permalink
Reorder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Aug 20, 2024
1 parent 9355134 commit f64bf84
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/framework/src/Support/Filesystem/MediaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ public function getIdentifier(): string
}

/**
* Get the file information as an array.
*
* @return array{name: string, path: string, length: int, mimeType: string, hash: string}
* Get a relative web link to the media file.
*/
public function toArray(): array
public function getLink(): string
{
return array_merge(parent::toArray(), [
'length' => $this->getContentLength(),
'mimeType' => $this->getMimeType(),
'hash' => $this->getHash(),
]);
$name = $this->getIdentifier();

$name = Str::start($name, Hyde::getMediaOutputDirectory().'/');

if (Hyde::hasSiteUrl()) {
return Hyperlinks::withCacheBusting(Hyde::url($name), $name);
}

return Hyperlinks::withCacheBusting(Hyde::relativeLink($name), $name);
}

/**
Expand Down Expand Up @@ -139,19 +141,17 @@ public function getHash(): string
}

/**
* Get a relative web link to the media file.
* Get the file information as an array.
*
* @return array{name: string, path: string, length: int, mimeType: string, hash: string}
*/
public function getLink(): string
public function toArray(): array
{
$name = $this->getIdentifier();

$name = Str::start($name, Hyde::getMediaOutputDirectory().'/');

if (Hyde::hasSiteUrl()) {
return Hyperlinks::withCacheBusting(Hyde::url($name), $name);
}

return Hyperlinks::withCacheBusting(Hyde::relativeLink($name), $name);
return array_merge(parent::toArray(), [
'length' => $this->getContentLength(),
'mimeType' => $this->getMimeType(),
'hash' => $this->getHash(),
]);
}

/** @internal */
Expand Down

0 comments on commit f64bf84

Please sign in to comment.