-
-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Event class and improve architecture with caching and logging #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dffab87
refactor: simplify platform file handling in Event class and related …
tanhongit 36e9bb3
refactor: PHP 8.5 + architecture improvements
tanhongit 5b0d6eb
Fix styling
tanhongit dece2c4
refactor: replace empty() with explicit checks, fix null safety
tanhongit 307fdc4
feat: update PHP and Laravel versions in CI configurations
tanhongit 605316b
fix: update phpstan/phpstan-deprecation-rules version to ^2.0 in comp…
tanhongit 0c638c7
fix: update file paths for event configurations to use storage directory
tanhongit 9a091aa
fix: resolve PHPStan level 9 errors in core package
tanhongit 5fe979c
refactor: migrate platform constants from EventConstant to Platform enum
tanhongit f85264d
fix: update file paths for event configurations in tests and settings
tanhongit fe7e812
feat: update PHP version to 8.4 in Scrutinizer configuration
tanhongit 5210f63
fix: downgrade PHP version to 8.3 in Scrutinizer configuration
tanhongit 4b7c958
Apply suggestion from @Copilot
tanhongit dd53969
Apply suggestion from @Copilot
tanhongit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ build: | |
| override: [ php-scrutinizer-run ] | ||
| environment: | ||
| php: | ||
| version: 8.2 | ||
| version: 8.3 | ||
|
|
||
| checks: | ||
| php: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,3 @@ parameters: | |
| - src | ||
| - config | ||
| tmpDir: build/phpstan | ||
| checkMissingIterableValueType: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
|
|
||
| namespace CSlant\TelegramGitNotifier\DTOs; | ||
|
|
||
| readonly class ChatTarget | ||
| { | ||
| /** | ||
| * @param string $chatId | ||
| * @param list<string> $threadIds | ||
| */ | ||
| public function __construct( | ||
| public string $chatId, | ||
| public array $threadIds = [], | ||
| ) { | ||
| } | ||
|
|
||
| public function hasThreads(): bool | ||
| { | ||
| return $this->threadIds !== []; | ||
| } | ||
|
|
||
| /** | ||
| * Parse a single "chatId:thread1,thread2" string. | ||
| */ | ||
| public static function fromString(string $raw): self | ||
| { | ||
| [$chatId, $threadIds] = explode(':', $raw) + [null, null]; | ||
|
|
||
| return new self( | ||
| chatId: (string) $chatId, | ||
| threadIds: $threadIds ? explode(',', $threadIds) : [], | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Parse "id1;id2:t1,t2;id3" format into an array of ChatTarget. | ||
| * | ||
| * @return list<self> | ||
| */ | ||
| public static function parseMultiple(string $raw): array | ||
| { | ||
| if (trim($raw) === '') { | ||
| return []; | ||
| } | ||
|
|
||
| return array_map( | ||
| static fn (string $pair) => self::fromString($pair), | ||
| explode(';', $raw), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <?php | ||
|
|
||
| namespace CSlant\TelegramGitNotifier\Enums; | ||
|
|
||
| enum Platform: string | ||
| { | ||
| case GITHUB = 'github'; | ||
| case GITLAB = 'gitlab'; | ||
|
|
||
| public const DEFAULT = 'github'; | ||
|
|
||
| public function eventSeparator(): string | ||
| { | ||
| return match ($this) { | ||
| self::GITHUB => 'gh.', | ||
| self::GITLAB => 'gl.', | ||
| }; | ||
| } | ||
|
|
||
| public function webhookEventHeader(): string | ||
| { | ||
| return match ($this) { | ||
| self::GITHUB => 'HTTP_X_GITHUB_EVENT', | ||
| self::GITLAB => 'HTTP_X_GITLAB_EVENT', | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, string> | ||
| */ | ||
| public static function webhookEventHeaders(): array | ||
| { | ||
| return array_combine( | ||
| array_map(fn (self $p) => $p->value, self::cases()), | ||
| array_map(fn (self $p) => $p->webhookEventHeader(), self::cases()), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, string> | ||
| */ | ||
| public static function eventSeparators(): array | ||
| { | ||
| return array_combine( | ||
| array_map(fn (self $p) => $p->value, self::cases()), | ||
| array_map(fn (self $p) => $p->eventSeparator(), self::cases()), | ||
| ); | ||
| } | ||
|
|
||
| public static function default(): self | ||
| { | ||
| return self::GITHUB; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Platformenum introduces methodswebhookEventHeaders(),eventSeparators(), anddefault()that are never called anywhere in the codebase. Additionally, the data they return (webhook event headers and event separators) duplicates what's already inEventConstant::WEBHOOK_EVENT_HEADERandEventConstant::PLATFORM_EVENT_SEPARATOR. This creates a maintenance burden since both places need to stay in sync when new platforms are added. If the enum is the canonical source of truth, the constants should be removed and replaced with enum usages. If constants are canonical, the static methods on the enum are redundant.