I have come up with the following design for my requirement and want know if there is a better way to do it or if you have any feedback on the design.
Requirement
Assume that an app provides different add-ons and each of these add-ons have a licence. The user is given a license key and he can activate/deactivate the license key to use that add-on.
There is also a bundle license which provides the user with a single license key that can be used to activate/deactivate all the add-ons. But there can be only one bundle license in the app.
This will be implemented in PHP.
Design
This is the design that I have come up with.
class BaseLicense {
protected $license_key;
protected $addon_name;
public abstract activate();
public abstract deactivate();
public abstract is_active();
}
class License extends BaseLicense {
// Inherit abstract methods
}
class BundleLicense extends BaseLicense {
// Inherit abstract methods
// Singleton since there can be only one bundle license.
}
BaseLicense, how does it know if that license is applicable to add-on X and not exclusively for add-on Y?addon_nameproperty.