Skip to content

Turns arrays intpo objects and vice verse. Provides a single interface and a pseudo trait to implement models.

License

Notifications You must be signed in to change notification settings

noptic/dalia-inject

Repository files navigation

dalia-it/dalia-inject

Provides a simple injection pattern for models. Instead of using the constructor you call the static method inject and pass it a associative array.

Usage

###PHP 5.4

class User{
    use daliaIT\inject\Inject;
    protected $givenName, $familyName;
    public function printName(){
        echo "$familyName, $givenName";
    }
}

User::inject([
    'givenName' => 'Martha', 
    'familyName' => 'Jones'])
    ->printName();

###PHP 5.3

class User{
    #@import daliaIT\inject\Inject @#
    protected $givenName, $familyName;
    public function printName(){
        echo "$familyName, $givenName";
    }
}

User::inject(array(
    'givenName' => 'Martha', 
    'familyName' => 'Jones'))
    ->printName();

About

Turns arrays intpo objects and vice verse. Provides a single interface and a pseudo trait to implement models.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages