You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently many of the methods take arbitrary arrays as parameters. This makes it difficult to understand what exact data each function is expecting. I think in the long-term the integration library should be refactored to pass objects instead of arrays as function arguments.
That way:
Type hinting could be used to clarify what arguments each method is expecting
Properties could be accessed with class methods instead of arbitrary array keys
// Fails if passed anything else but an object that implements the// \H5P\Content interface. Therefore developers know exactly// what they are supposed to pass into the method.publicfunctionfilterParameters(\H5P\Content$content) {
// Also you now have easy access to content methods:if ($content->isFiltered()) {
// Some logic here
}
}
Splitting the framework logic to multiple interfaces
Currently the library requires a framework to implement only one interface: H5PFrameworkInterface.
This causes too much unrelated logic to be inserted into the same class. Splitting the implementation to multiple different interfaces would:
Make it clearer what is expected from each class and method
Increase the usefulness of input type hinting, as each class or method could define the exact object(s) that they need in order to do their job
Dependency injection
Reduces global state and global functions
Makes it possible to write unit tests with mocked dependencies
The text was updated successfully, but these errors were encountered:
Some ideas for future versions of the library:
Passing objects as arguments
Currently many of the methods take arbitrary arrays as parameters. This makes it difficult to understand what exact data each function is expecting. I think in the long-term the integration library should be refactored to pass objects instead of arrays as function arguments.
That way:
Splitting the framework logic to multiple interfaces
Currently the library requires a framework to implement only one interface:
H5PFrameworkInterface
.This causes too much unrelated logic to be inserted into the same class. Splitting the implementation to multiple different interfaces would:
Dependency injection
The text was updated successfully, but these errors were encountered: