Skip to content

Commit

Permalink
fix: phpstan test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Oct 30, 2023
1 parent 75aadbd commit 07b74e4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/Interfaces/EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LbilTech\TelegramGitNotifier\Interfaces;

use LbilTech\TelegramGitNotifier\Constants\EventConstant;
use LbilTech\TelegramGitNotifier\Trait\ActionEventTrait;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -20,13 +21,13 @@ public function getActionOfEvent(object $payload): string;
/**
* Set platform and platform file for event
*
* @param string $platform
* @param string|null $platform
* @param string|null $platformFile
*
* @return void
* @see EventTrait::setPlatFormForEvent()
*/
public function setPlatFormForEvent(string $platform, string $platformFile = null): void;
public function setPlatFormForEvent(?string $platform = EventConstant::DEFAULT_PLATFORM, string $platformFile = null): void;

/**
* Set event config and get event name
Expand Down
11 changes: 6 additions & 5 deletions src/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ public function getEventConfig(): array
/**
* Set event config
*
* @param string $platform
* @param string|null $platform
*
* @return void
*/
public function setEventConfig(
string $platform = EventConstant::DEFAULT_PLATFORM
string $platform = null
): void {
$this->platform = $platform;
$this->platform = $platform ?? EventConstant::DEFAULT_PLATFORM;

if (file_exists($this->platformFile)) {
$json = file_get_contents($this->platformFile);
$json = file_get_contents($this->platformFile);

if (!empty($json)) {
$this->eventConfig = json_decode($json, true);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public function getSettingFile(): string
*/
public function setSettingConfig(): void
{
if (file_exists($this->settingFile)) {
$json = file_get_contents($this->settingFile);
$json = file_get_contents($this->settingFile);

if (!empty($json)) {
$this->settings = json_decode($json, true);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Trait/EventSettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public function getPlatformFromCallback(
return $platform;
}

if (str_contains($callback, EventConstant::GITHUB_EVENT_SEPARATOR)) {
if ($callback && str_contains($callback, EventConstant::GITHUB_EVENT_SEPARATOR)) {
return 'github';
} elseif (str_contains($callback, EventConstant::GITLAB_EVENT_SEPARATOR)) {
} elseif ($callback && str_contains($callback, EventConstant::GITLAB_EVENT_SEPARATOR)) {
return 'gitlab';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Trait/EventTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait EventTrait
{
use ActionEventTrait;

public function setPlatFormForEvent(string $platform, string $platformFile = null): void
public function setPlatFormForEvent(?string $platform = EventConstant::DEFAULT_PLATFORM, string $platformFile = null): void
{
/** @var array $platformFileDefaults<platform, platformFile> */
$platformFileDefaults = config('telegram-git-notifier.data_file.platform');
Expand Down

0 comments on commit 07b74e4

Please sign in to comment.