Sons of PHP
Source Code
  • 🏠Home
  • Contributor Covenant Code of Conduct
  • Getting Help
  • Reporting Issues
  • Security Policy
  • 🪈Bard
    • Overview
    • Commands
  • Symfony Bundles
    • Feature Toggle
  • Contracts
    • Contracts Overview
    • Common
    • Cookie
    • CQRS
    • Filesystem
    • Mailer
    • Pager
    • Registry
    • State Machine
  • 📦Components
    • Assert
    • Cache
      • Adapters
      • Marshallers
    • Clock
    • Container
    • Cookie
    • CQRS
    • Event Dispatcher
    • Event Sourcing
      • Aggregates
        • Aggregate Repository
      • Event Messages
        • Using the Serializable Event Message
        • Message Enrichers
        • Message Serializers
        • Message Repository
        • Message Upcasters
    • Feature Toggle
    • Filesystem
      • Adapters
    • Http Factory
    • Http Handler
    • Http Message
    • JSON
    • Link
    • Logger
      • Handlers
      • Enrichers
      • Filters
      • Formatters
    • Mailer
      • Transports
    • Money
      • Currency Providers
      • Operators
      • Queries
    • Pager
      • Adapters
    • Registry
    • State Machine
    • Version
  • 💁Contributing
    • Contributing Overview
    • Contributing Code
    • Discussions
    • Documentation
Powered by GitBook
On this page
  • Implementation
  • Method Naming
  • with*
  • has*
  • is*
  • get*
  • set*
  • to*

Was this helpful?

Edit on GitHub
  1. Contracts

Contracts Overview

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 ToggleNextCommon

Last updated 8 months ago

Was this helpful?