2017 © Pedro Peláez
 

library key-value-coding

PHP library to enable key-value coding for your objects.

image

tasoft/key-value-coding

PHP library to enable key-value coding for your objects.

  • Tuesday, March 7, 2017
  • by tasoft
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Key Value Coding

PHP Library to implement key-value coding This library defined 3 interfaces to enable key-value coding, key-value changing and key-value observing. Key-value coding is known as accessing properties, such as attributes or relationships of an object via keys. The key-value-coding library ships with 2 traits that implement the coding and changing interfaces., (*1)

Usage

Every object that has methods named get* and set* can be used for key-value coding. The Object\CodingTrait implements the default mechanism which has the following workflow:
Getting a key:, (*2)

echo $object->userName;

will do:, (*3)

$object->__get("userName");
$object->valueForKey("userName");
$object->getDefinedKeys();
// If key does exist
$object->getUserName();
// If key does not exist
$object->valueForUndefinedKey("userName");

and the same for, (*4)

$object->userName = "tasoft";

but using the __set, setValueForKey, setUserName or setValueForUndefinedKey instead., (*5)

Key Paths

Keypaths are defined as identifier to trace objects by its relationships. For example, an address object contains an attribute named country and a user contains a relationship to an address object, you can access the country attribute by using, (*6)

echo $user->valueForKeyPath("address.country");
// or
echo $user["address.country"];

The Versions

07/03 2017

dev-master

9999999-dev https://github.com/TASoftApplications/key-value-coding

PHP library to enable key-value coding for your objects.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

key value coding tracing

07/03 2017

v1.0.1

1.0.1.0 https://github.com/TASoftApplications/key-value-coding

PHP library to enable key-value coding for your objects.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

key value coding tracing

07/03 2017

1.1

1.1.0.0 https://github.com/TASoftApplications/key-value-coding

PHP library to enable key-value coding for your objects.

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

key value coding tracing