ContractsExceptions

Since v1.2016052101

Description

ContractsExceptions is a FactoryList. It provides factory methods for all exceptions that the Contracts Library can throw.

Public Interface

ContractsExceptions has the following public interface.

// ContractsExceptions lives in this namespace
namespace GanbaroDigital\Contracts\V1\Exceptions;

// our base classes and interfaces
use GanbaroDigital\DIContainers\V1\FactoryList\Containers\FactoryListContainer;
use GanbaroDigital\DIContainers\V1\Interfaces\FactoryList;

class ContractsExceptions extends FactoryListContainer
{
    public function __construct();

    /**
     * return the full list of factories as a real PHP array
     *
     * @return array
     * @inheritedFrom FactoryList
     */
    public function getList();
}

How To Use

Construction

Here's how to build a new instance of ContractsExceptions.

use GanbaroDigital\Contracts\V1\Exceptions\ContractsExceptions;

$diContainer = new ContractsExceptions;

Creating A New Exception

Treat ContractsExceptions as a PHP array that contains factory methods. Each factory's name is the same class::method that you would use to call the exception's factory directly.

use GanbaroDigital\Contracts\V1\Exceptions\ContractsExceptions;

$diContainer = new ContractsExceptions;

throw $diContainer['ContractFailed::newFromVar'](false);

Class Contract

Here is the contract for this class:

GanbaroDigital\Contracts\V1\Exceptions\ContractsExceptions
 [x] Can instantiate
 [x] Is factory list
 [x] has factory for ContractFailed newFromVar

Class contracts are built from this class's unit tests.

Future releases of this class will not break this contract.

Future releases of this class may add to this contract. New additions may include:

  • clarifying existing behaviour (e.g. stricter contract around input or return types)
  • add new behaviours (e.g. extra class methods)

When you use this class, you can only rely on the behaviours documented by this contract.

If you:

  • find other ways to use this class,
  • or depend on behaviours that are not covered by a unit test,
  • or depend on undocumented internal states of this class,

... your code may not work in the future.

Notes

None at this time.