2017 © Pedro Peláez
 

library spf-contracts

Defines the interfaces and traits for the services used throughout SPF

image

simon-downes/spf-contracts

Defines the interfaces and traits for the services used throughout SPF

  • Monday, July 23, 2018
  • by simon-downes
  • Repository
  • 0 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SPF Contracts

Introduction

This package defines the interfaces and traits for the core services used throughout SPF. e.g. spf\contracts\database\DatabaseConnection defines the contract for accessing a database, while the spf\contracts\support\collections\Dictionary defines methods for operating on a collection of key/value pairs., (*1)

Each directory corresponds to a SPF package that provides implementations of the interfaces defined in that directory. For example, the simon-downes/spf package contains implementions of spf\contracts\log\Logger., (*2)

Naming Conventions

Interfaces in this package are named in one of two ways:, (*3)

  • As a singular noun (e.g. Dictionary, DatabaseConnection, Filter)
  • As a noun or verb suffixed with "-able" (e.g. Arrayable, Runnable)

The implementations of those interfaces within SPF packages are prefixed with Base., (*4)

  • DictionaryBaseDictionary
  • DatabaseConnectionBaseConnection
  • ConnectionManagerBaseConnectionManager
  • ProfilerBaseProfiler

Background

This package is based on gamernetwork/yolk-contracts. For more information on the history and relationship between Yolk and SPF please see the README of simon-downes/spf-core., (*5)

Why Contracts?

A separate contracts package provides two primary benefits:, (*6)

  • A quick reference point for all available contracts.
  • A single, decoupled package that promotes loose-coupling by separating interfaces from implementations.

Quick Reference

Having all of the framework's services neatly defined within interfaces provides succinct documentation to available features., (*7)

Rather than tracking down which methods are available within a large, complicated class, you can refer to a simpler, cleaner interface., (*8)

Loose Coupling

Wikipedia Reference, (*9)

SPF packages provide default and usually basic implementations of each contract; sometimes these might not be sufficient or quite right for a particular project., (*10)

By specifying contracts, code is no longer coupled to these specific implementations and you may easily write alternatives that better suit your project., (*11)

Likewise, you can switch between implementations without modifying any consuming code. The classic example being able to switch caching backends (e.g. Memory/Redis/Memcache) without modifying any code that uses the cache., (*12)

The Versions

23/07 2018

dev-master

9999999-dev

Defines the interfaces and traits for the services used throughout SPF

  Sources   Download

MIT

The Requires

  • php ~7.2

 

framework php spf