Skip to content

Commit dffab87

Browse files
committed
refactor: simplify platform file handling in Event class and related tests
1 parent 021e80b commit dffab87

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

src/Models/Event.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,13 @@ class Event
1010

1111
public string $platform = EventConstant::DEFAULT_PLATFORM;
1212

13-
private string $platformFile = '';
14-
15-
/**
16-
* @return string
17-
*/
18-
public function getPlatformFile(): string
19-
{
20-
return $this->platformFile;
21-
}
22-
23-
/**
24-
* @param string $platformFile
25-
*
26-
* @return void
27-
*/
28-
public function setPlatformFile(string $platformFile): void
29-
{
30-
$this->platformFile = $platformFile;
13+
public string $platformFile = '' {
14+
get {
15+
return $this->platformFile;
16+
}
17+
set {
18+
$this->platformFile = $value;
19+
}
3120
}
3221

3322
/**

src/Trait/EventTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function setPlatFormForEvent(?string $platform = EventConstant::DEFAULT_P
1414
{
1515
/** @var array $platformFileDefaults<platform, platformFile> */
1616
$platformFileDefaults = config('telegram-git-notifier.data_file.platform');
17-
$this->event->setPlatformFile($platformFile ?? $platformFileDefaults[$platform]);
17+
$this->event = $platformFile ?? $platformFileDefaults[$platform];
1818
$this->event->setEventConfig($platform);
1919
}
2020

@@ -38,7 +38,7 @@ public function validatePlatformFile(): void
3838
if (empty($this->event->getEventConfig())) {
3939
throw ConfigFileException::platformFile(
4040
$this->event->platform,
41-
$this->event->getPlatformFile()
41+
$this->event
4242
);
4343
}
4444
}

tests/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
it('platform can be set for event with platform file', function () {
2424
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json');
2525
expect($this->bot->event->platform)->toBe('gitlab')
26-
->and($this->bot->event->getPlatformFile())
26+
->and($this->bot)
2727
->toBe('storage/json/tgn/gitlab-events.json');
2828
});
2929

0 commit comments

Comments
 (0)