Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sugeng-sulistiyawan committed Oct 20, 2024
1 parent 4854a5e commit 3842734
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/AbstractComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* @method string temporaryUrl(string $path, \DateTimeInterface $expiresAt, array $config = [])
* @method string checksum(string $path, array $config = [])
*
* @property string $action
*
* @link https://sugengsulistiyawan.my.id/
* @author Sugeng Sulistiyawan <[email protected]>
* @copyright Copyright (c) 2023
Expand Down
2 changes: 1 addition & 1 deletion src/actions/FileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function run($data = null)
$filesystem = Yii::$app->get($this->component);

try {
$params = Json::decode($filesystem?->decrypt($data));
$params = Json::decode($filesystem->/** @scrutinizer ignore-call */decrypt($data));

$now = (int) (new DateTimeImmutable())->getTimestamp();
$expires = (int) $params['expires'];
Expand Down
14 changes: 7 additions & 7 deletions src/traits/UrlGeneratorAdapterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
trait UrlGeneratorAdapterTrait
{
/**
* @var AbstractComponent|UrlGeneratorComponentTrait
* @var AbstractComponent
*/
public $component;

Expand All @@ -31,30 +31,30 @@ trait UrlGeneratorAdapterTrait
public function publicUrl(string $path, /** @scrutinizer ignore-unused */Config $config): string
{
// TODO: Use absolute path and don't encrypt
if ($this->skipPrefixer !== false && $this->component?->prefix) {
$prefixer = new PathPrefixer((string) $this->component?->prefix);
if ($this->skipPrefixer !== false && $this->component->prefix) {
$prefixer = new PathPrefixer((string) $this->component->prefix);
$path = $prefixer->stripPrefix($path);
}
$params = [
'path' => $path,
'expires' => 0,
];

return Url::toRoute([$this->component?->action, 'data' => $this->component?->encrypt(Json::encode($params))], true);
return Url::toRoute([$this->component->action, 'data' => $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params))], true);
}

public function temporaryUrl(string $path, DateTimeInterface $expiresAt, /** @scrutinizer ignore-unused */Config $config): string
{
// TODO: Use absolute path and don't encrypt
if ($this->skipPrefixer !== false && $this->component?->prefix) {
$prefixer = new PathPrefixer((string) $this->component?->prefix);
if ($this->skipPrefixer !== false && $this->component->prefix) {
$prefixer = new PathPrefixer((string) $this->component->prefix);
$path = $prefixer->stripPrefix($path);
}
$params = [
'path' => $path,
'expires' => (int) $expiresAt->getTimestamp(),
];

return Url::toRoute([$this->component?->action, 'data' => $this->component?->encrypt(Json::encode($params))], true);
return Url::toRoute([$this->component->action, 'data' => $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params))], true);
}
}

0 comments on commit 3842734

Please sign in to comment.