Skip to content

Commit

Permalink
Improve Docs
Browse files Browse the repository at this point in the history
Changed:
- Linked traits and interfaces
- Reorganized portions of "Delegates Data Lookup"
- Replaced bold lines with headings
- Added headings
  • Loading branch information
mcaskill committed May 10, 2018
1 parent 1f391d7 commit 2318d3f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
10 changes: 7 additions & 3 deletions docs/configurable-objects.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Configurable Objects

**Mixin**
#### Mixin

- `Charcoal\Config\ConfigrableInterface`
- `Charcoal\Config\ConfigurableTrait`
- [`Charcoal\Config\ConfigrableInterface`](src/Charcoal/Config/ConfigrableInterface.php)
- [`Charcoal\Config\ConfigurableTrait`](src/Charcoal/Config/ConfigurableTrait.php)

Configurable objects (which could have been called "_Config Aware_") can have an associated Config object that can help define various properties, states, or other.

#### API

The trait provides three methods: `config()`, `setConfig()`, and `createConfig()`.

- `config()` — Retrieve the Config object or the value of a given key.
Expand Down Expand Up @@ -35,6 +37,8 @@ The trait provides three methods: `config()`, `setConfig()`, and `createConfig()
protected ConfigurableTrait::createConfig ( [ mixed $data = null ] ) : ConfigInterface
```

#### Examples

**Example #1: Implementation of the mixin**

```php
Expand Down
27 changes: 16 additions & 11 deletions docs/delegates-lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ Delegates allow several objects to share values and act as fallbacks when the cu

> 👉 The delegates feature is only implemented by the `Config` class, by default.
**Mixin**
#### Mixin

- `Charcoal\Config\DelegatesAwareInterface`
- `Charcoal\Config\DelegatesAwareTrait`
- [`Charcoal\Config\DelegatesAwareInterface`](src/Charcoal/Config/DelegatesAwareInterface.php)
- [`Charcoal\Config\DelegatesAwareTrait`](src/Charcoal/Config/DelegatesAwareTrait.php)

In Config objects, _delegate objects_ are regsitered to an internal stack. If a data key cannot be resolved, the Config iterates over each delegate in the stack and stops on
the first match containing a value that is not `NULL`.
#### API

Delegates can be registered with:

- `setDelegates()` — to replace stack with a new collection of delegates.
- `addDelegate()` — to add a delegate to the end of the stack.
- `prependDelegate()` — to add a delegate to the beginning of the stack.



## Config Object

In Config objects, _delegate objects_ are regsitered to an internal stack. If a data key cannot be resolved, the Config iterates over each delegate in the stack and stops on the first match containing a value that is not `NULL`.

```php
use Charcoal\Config\GenericConfig as Config;
Expand Down Expand Up @@ -39,9 +50,3 @@ $cfg = new Config('path/config.json', [ $del1, $del2 ]);
```

> 👉 The order of the delegate stack is important. They are looked in the order they are added, so the first match is returned. Use the `prependDelegate($delegate)` method to add a delegate to the front of the stack (top priority).
Delegates can be registered with:

- `setDelegates()` — to replace stack with a new collection of delegates.
- `addDelegate()` — to add a delegate to the end of the stack.
- `prependDelegate()` — to add a delegate to the beginning of the stack.
4 changes: 2 additions & 2 deletions docs/file-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Array data can be parsed from files depending on the file extension. This is use

> 👉 The file loading feature is only implemented by the `Config` class, by default.
**Mixin**
#### Mixin

- [`Charcoal\Config\FileAwareInterface`](src/Charcoal/Config/FileAwareInterface.php)
- [`Charcoal\Config\FileAwareTrait`](src/Charcoal/Config/FileAwareTrait.php)

**Supported File Formats**
#### Supported File Formats

- [INI](#ini-configuration-files)
- [JSON](#json-configuration-files)
Expand Down
10 changes: 7 additions & 3 deletions docs/separator-lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ It is possible to lookup, retrieve, assign, or merge values in multi-dimensional

> 👉 The key separator feature is only implemented by the `Config` class, by default.
**Mixin**
#### Mixin

- `Charcoal\Config\SeparatorAwareInterface`
- `Charcoal\Config\SeparatorAwareTrait`
- [`Charcoal\Config\SeparatorAwareInterface`](src/Charcoal/Config/SeparatorAwareInterface.php)
- [`Charcoal\Config\SeparatorAwareTrait`](src/Charcoal/Config/SeparatorAwareTrait.php)



## Config Object

In Config objects, the default separator is the period character (`.`). The token can be retrieved with the `separator()` method and customized using `setSeparator()` method.

Expand Down

0 comments on commit 2318d3f

Please sign in to comment.