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

chore: add initial events implementation #13

Merged
merged 1 commit into from
Dec 21, 2020
Merged

chore: add initial events implementation #13

merged 1 commit into from
Dec 21, 2020

Conversation

brianium
Copy link
Contributor

@brianium brianium commented Dec 17, 2020

This is the initial event system for dues. Fairly standard run of the mill observer pattern.

An example listener may do something with taxes:

class TaxListener extends BaseEventListener
{
    public function onBeforeCreateSubscription(Subscription $subscription)
    {
        $tax = $this->calculateTax();
        $subscription->addOn(new AddOn('tax-fun', 1, new Price($tax)));
    }
}

// wherever Dues is instantiated:
$dues->addListener(new TaxListener());

A listener just has to implement the EventListener interface. A BaseEventListener class is provided to provide a stub implementation for all events.

@sonarcloud
Copy link

sonarcloud bot commented Dec 17, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@brianium brianium merged commit 98cec8a into main Dec 21, 2020
@brianium brianium deleted the feat/events branch December 21, 2020 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants