2017 © Pedro Peláez
 

library settings

A collection of custom selectable elements

image

superruzafa/settings

A collection of custom selectable elements

  • Thursday, October 16, 2014
  • by superruzafa
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Settings

Build Status, (*1)

Settings is a library for manage collection of elements. Each element is included into the collection along with some metadata. This metadata could be used later for enumerate a subset of elements. The elements are selected using selectors., (*2)

Built-in selectors

Settings comes with some predefined selectors:, (*3)

Tag selectors

This kind of selector allow to store the elements with some associated tags. There is two classes of tags:, (*4)

  • Required tags: 'required', 'necessary
  • Optional tags (between brackets): '[optional]', '[redundant]'

Both required and optional tags have special meanings depending on th type of tag selector. Optional tags are usually used for disambiguation purposes., (*5)

Strict tag selector

This selector selects only those items whose metatags intersect with the selector tags:, (*6)

``` php <?php, (*7)

use Superruzafa\Settings\Collection; use Superruzafa\Settings\Selector\StrictTagSelector;, (*8)

$collection = new Collection(); $collection->add('item1', array('tag1', '[tag2]', 'tag3')); $collection->add('item2', array('tag1', '[tag2]')); $collection->add('item3', array('[tag1]', 'tag2', 'foo')); $collection->add('item4', array('[tag1]', 'tag2', '[bar]'));, (*9)

// The selector would select those items containing both tag1 and tag2 tags. // If the item defines any other required tag that is not matched then the item is discarded. $selector = new StrictTagSelector('tag1', 'tag2'); $selected = $collection->setSelector($selector)->select(); // $selected = ['item2', 'item4'], (*10)


#### Lazy tag selector This selector select those items whose metatags are a superset of the selector tags. ``` php <?php use Superruzafa\Settings\Collection; use Superruzafa\Settings\Selector\LazyTagSelector; $collection = new Collection(); $collection->add('item1', array('tag1', '[tag2]', 'tag3')); $collection->add('item2', array('tag1', '[tag2]')); $collection->add('item3', array('[tag1]', 'tag2', 'foo')); $collection->add('item4', array('[tag1]', 'foo', '[bar]')); // The selector would select those items containing at least both `tag1` and `tag2` tags. // Other tags (required or optional) doesn't affect. $selector = new LazyTagSelector('tag1', 'tag2'); $selected = $collection->setSelector($selector)->select(); // $selected = ['item1', 'item2', 'item3']

Domain selector

This selector uses domain names to select elements within a collection., (*11)

``` php <?php, (*12)

use Superruzafa\Settings\Collection; use Superruzafa\Settings\Selector\DomainSelector;, (*13)

$collection = new Collection(); $collection->add('item1', 'github.com'); $collection->add('item2', 'www.github.com'); $collection->add('item3', 'example.com'); $collection->add('item4', 'ftp.example.com');, (*14)

// The selector would select those items associated with github.com or *.github.com. $selector = new DomainSelector('github.com'); $selected = $collection->setSelector($selector)->select(); // $selected = ['item1', 'item2'], (*15)


### Other selectors #### AlwaysSelector This selector always selects every element in the collection. ``` php $selector = new AlwaysSelector(); $selected = $collection->setSelector($selector)>select(); // $selected = all elements in the collection

NeverSelector

As opposite to the AlwaysSelector, this selector selects no element in the collection., (*16)

php $selector = new NeverSelector(); $selected = $collection->setSelector($selector)>select(); // $selected = array(), (*17)

Selection methods

Each selector comes with one of these operations:, (*18)

  • select() Selects all those elements selected by the selector.
  • selectOne() Selects the first element selected by the selector
  • discard() Select all those elements not selected by the selector.
  • discardOne() Select the first element not selected by the selector.

The Versions

16/10 2014

dev-master

9999999-dev https://github.com/superruzafa/settings

A collection of custom selectable elements

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Alfonso Ruzafa

settings config profiles selectable

12/10 2014

1.1.0

1.1.0.0 https://github.com/superruzafa/settings

A collection of custom selectable elements

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Alfonso Ruzafa

settings config profiles selectable

12/10 2014

1.0.0

1.0.0.0 https://github.com/superruzafa/settings

A collection of custom selectable elements

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Alfonso Ruzafa

settings config profiles selectable