Skip to content
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

Add hooks to enable customization by users #291

Closed
villfa opened this issue Jan 29, 2021 · 1 comment · Fixed by #304
Closed

Add hooks to enable customization by users #291

villfa opened this issue Jan 29, 2021 · 1 comment · Fixed by #304

Comments

@villfa
Copy link
Collaborator

villfa commented Jan 29, 2021

There are 2 events I have in mind:

  • AfterFileAnalysis
  • AfterAnalysis

The users could hook on the event of their choice by implementing the corresponding interfaces.

Example:

interface AfterFileAnalysisHook {
    public function afterFileAnalysis(AfterFileAnalysisEvent $event): void;
}

interface AfterFileAnalysisEvent {
    public function getFilePath(): string;
    public function getNumberOfChanges(): int;
    public function getCyclomaticComplexity(): int;
    //public function getScore(): float; // nope, the scores are calculated at the end
}

interface AfterAnalysisHook {
    public function afterAnalysis(AfterAnalysisEvent $event): void;
}

interface AfterAnalysisEvent {
    public function getNumberOfFiles(): int;
    public function getMaxNumberOfChanges(): int;
    public function getMaxCyclomaticComplexity(): int;
    public function getMaxScore(): float;
}
@villfa
Copy link
Collaborator Author

villfa commented Jan 29, 2021

I'm wondering it the hooks methods shouldn't be static. That way we don't have to worry about how to instantiate the hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant