2017 © Pedro Peláez
 

library discovery

Alternative method for discovering meta-information about a class.

image

rhys-mcguckin/discovery

Alternative method for discovering meta-information about a class.

  • Monday, August 10, 2015
  • by rhys-mcguckin
  • Repository
  • 2 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

License

This code is released under the MIT and LGPL licences., (*1)

Purpose

The purpose of this repository is to provide a simplified method of discovering the usage of classes, along with the metadata required to identify the instances of classes., (*2)

This is an alternative to code annotations., (*3)

Usage

Using within PHP requires adding at least a source, with an optional cache., (*4)

$discovery = new Discovery\Discovery();

// Adds a Psr-0 source list.
$discovery->addSource(new Psr(__DIR__ . '/lib'))

// Adds a Psr-4 source list.
$discovery->addSource(new Psr(__DIR__ . '/src', 'Example\\Psr4'))

// Adds a composer source list.
$discovery->addSource(new Composer(__DIR__))


// Sets the meta class that is by default generated by getMeta().
$discovery->setCache(new Cache());


// Get the meta information based on the key 'machine'.
$meta = $discovery->getMeta('type', 'subtype');

// Get a list of all types defined by the meta information.
$types = $discovery->getTypes();

// Get a list of all subtypes defined by the meta information.
$types = $discovery->getSubtype('test');

The YAML files are placed in the same folder or directory as the class for which it is providing meta-information., (*5)

The structure of the YAML file aside from the 'type', 'subtype', 'meta' and 'arguments' keys, is left up to the developer with respect to the class., (*6)

The predefined keys: * 'type' This represents the general type of class this is meant to represent. * 'subtype' This represents the more specific type of class. * 'meta' This is the meta class used to generate meta-information regarding the class. * 'arguments' These are arguments that are specifically passed when instantiating the referring class., (*7)

Minimum required:, (*8)

type: type-name
subtype: type-name

Example:, (*9)

type: type-name
subtype: type-name
meta: "Alternative\\Meta\\Class"
arguments: ['arg1', {'option1': 'value'}]
settings:
  option1: 1
  option2:
    - Option 2 Value 1
    - Option 2 Value 2

The Versions

10/08 2015

dev-master

9999999-dev

Alternative method for discovering meta-information about a class.

  Sources   Download

The Requires

 

10/08 2015

v1.0.1

1.0.1.0

Alternative method for discovering meta-information about a class.

  Sources   Download

The Requires

 

30/05 2015

v1.0

1.0.0.0

Alternative method for discovering meta-information about a class.

  Sources   Download

The Requires