2017 © Pedro Peláez
 

library contract

Simple contracts library for PHP

image

plaf/contract

Simple contracts library for PHP

  • Monday, August 12, 2013
  • by tverdohleb
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Plaf\Contract

Simple contracts for PHP

A part of Plaf - PHP library: Additional functionality, (*1)

Functionality for ensuring contract compliance in terms of value type / range constraints. It should not be treated as validation, but specification of usage boundaries for programmers. Correctly covered code will behave predictable: it will work as designed by it's author or not work at all., (*2)

Usage example:

use Plaf\Contract\Contract;

class EntitySaver {

    public function saveEntity($entity) {
        Contract::ensureNotNull($entity);
    }

}


use Plaf\Contract\Contract;

class Order {

    const STATE_NEW;
    const STATE_PREPARING;
    const STATE_SHIPPED;
    const STATE_COMPLETED;

    private $state;

    public function setState($state) {
        Contract::ensureInArray($state, array(
            self::STATE_NEW,
            self::STATE_PREPARING,
            self::STATE_SHIPPED,
            self::STATE_COMPLETED
        ));
    }

}

The Versions

12/08 2013

dev-master

9999999-dev

Simple contracts library for PHP

  Sources   Download

The Development Requires

by Valeriy Tverdohleb