From 3842734122c13d21eacdd030082d9129e4901e25 Mon Sep 17 00:00:00 2001 From: Sugeng Sulistiyawan Date: Sun, 20 Oct 2024 12:12:14 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AbstractComponent.php | 2 ++ src/actions/FileAction.php | 2 +- src/traits/UrlGeneratorAdapterTrait.php | 14 +++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AbstractComponent.php b/src/AbstractComponent.php index 91eeb4f..53461b7 100644 --- a/src/AbstractComponent.php +++ b/src/AbstractComponent.php @@ -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 * @copyright Copyright (c) 2023 diff --git a/src/actions/FileAction.php b/src/actions/FileAction.php index 58c3169..b67d154 100644 --- a/src/actions/FileAction.php +++ b/src/actions/FileAction.php @@ -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']; diff --git a/src/traits/UrlGeneratorAdapterTrait.php b/src/traits/UrlGeneratorAdapterTrait.php index 8a6a5b8..50e05b2 100644 --- a/src/traits/UrlGeneratorAdapterTrait.php +++ b/src/traits/UrlGeneratorAdapterTrait.php @@ -19,7 +19,7 @@ trait UrlGeneratorAdapterTrait { /** - * @var AbstractComponent|UrlGeneratorComponentTrait + * @var AbstractComponent */ public $component; @@ -31,8 +31,8 @@ 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 = [ @@ -40,14 +40,14 @@ public function publicUrl(string $path, /** @scrutinizer ignore-unused */Config '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 = [ @@ -55,6 +55,6 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, /** @sc '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); } }