Skip to content

Commit

Permalink
improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pangolinkeys committed Nov 26, 2017
1 parent ce440b0 commit 08fd45d
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@ A php repository to simplify combining arrays.
----
## Usage
Add *Bindable* as a trait on the target classes.


use Bindable;


```php
use Bindable;
```
Implement the *getKeys()* method so the bind method knows how the array is keyed.


public function getKeys()
{
return array_keys($this->data);
}

```php
public function getKeys()
{
return array_keys($this->data);
}
```
Create a get method suffixed by the name of the target attribute which is passed a singular key from the *getKeys()* method and returns a reference to the desired position in the array.

public function &getAge($person)
{
return $this->data[ $person ]['Age'];
}
```php
public function &getAge($person)
{
return $this->data[ $person ]['Age'];
}
```
Finally, call bind and pass through the second object and the key which the bind should occur on.

$people->bind($preference, 'Age');

These methods should be implemented in both classes.

```php
$people->bind($preference, 'Age');
```
These methods should be implemented appropriately in both classes.
## Example
A working example of this can be found in the */example* directory.
A working example of this can be found in the */example* directory.

0 comments on commit 08fd45d

Please sign in to comment.