Skip to content


Contracts are interfaces that can be reusable across multiple different libraries and projects. The actual implementation of the interfaces is left up to you.

The interfaces also enhance existing PSRs.

Whenever possible, the components and projects created by Sons of PHP will implement these interfaces.


If you want to provide a concrete library for others to use, add this to your composer.json file.

    "provide": {
        "sonsofphp/common-implementation": "^1.0"

Method Naming

Functionality around method names are kept as similar as possible. They SHOULD follow this convention.


with* methods are meant to be used on value objects. They will return a new object with the value(s) modified.

Examples: - withFirstName


Will always return a boolean value. Used to check if a property or value exists on the object. Doesn't matter the type of the value.

Examples - hasFirstName


Will always return a boolean value.

Examples: - isNew - isDeleted


Used to return property values.

Examples: - getFirstName - getLastName


Used to set property values. SHOULD always return the same instance of the object to allow chaining.

Examples: - setFirstName - setLastName


Used to convert an object to a specific format.

Examples: - toJson - toString - toArray - toInteger - toFloat - toBoolean