GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sons of PHP
  • Source Code
  • Contracts

This view

  • Original page
  • New address

GeezerVison is showing docs.sonsofphp.com — Contracts Overview | Sons of PHP

For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Implementation

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*

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

Examples:

  • withFirstName

has*

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

is*

Will always return a boolean value.

Examples:

  • isNew

  • isDeleted

get*

Used to return property values.

Examples:

  • getFirstName

  • getLastName

set*

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

Examples:

  • setFirstName

  • setLastName

to*

Used to convert an object to a specific format.

Examples:

  • toJson

  • toString

  • toArray

  • toInteger

  • toFloat

  • toBoolean

PreviousFeature Toggle
NextCommon

Last updated 2 years ago

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.