dev-master
9999999-devAllows to attach some attributes to objects
MIT
The Development Requires
v0.1
0.1.0.0Allows to attach some attributes to objects
MIT
The Development Requires
 Wallogit.com
                    
                    2017 © Pedro PelĂĄez
                         Wallogit.com
                    
                    2017 © Pedro PelĂĄez
                    
                    
                    
                    
                
                
            
Allows to attach some attributes to objects
Allows to associate attributes with objects., (*1)
$ composer require lukaszmakuch/object-attribute-container
<?php
use lukaszmakuch\ObjectAttributeContainer\ObjectAttributeContainer;
use lukaszmakuch\ObjectAttributeContainer\Exception\AttributeNotFound;
use lukaszmakuch\ObjectAttributeContainer\Exception\ImpossibleToAddAttributes;
/* @var $attrContainer \ObjectAttributeContainer */
//create a test object
$obj = new \stdClass();
//associate parameters with the object
try {
    $attrContainer->addObjAttrs(
        $obj,
        ["attr-key" => "attr-val"]
    );
} catch (ImpossibleToAddAttributes $e) {
    //...
}
//check if there's a parameter with the given name
$attrContainer->objHasAttr($obj, "attr-key"); //true
//get that parameter value
try {
    $attrContainer->getObjAttrVal($obj, "attr-key"); //attr-val
} catch (AttributeNotFound $e) {
    //...
}
//remove that parameter
try {
    $attrContainer->remObjAttr($obj, "attr-key");
} catch (AttributeNotFound $e) {
    //...
}
<?php use lukaszmakuch\ObjectAttributeContainer\Impl\ObjectAttributeContainerImpl; use lukaszmakuch\ObjectAttributeContainer\Impl\ObjectAttributeContainerProxy; //default $container = new ObjectAttributeContainerImpl(); //proxy $containerProxy = new ObjectAttributeContainerProxy();
For more details check interfaces and test cases., (*2)
Allows to attach some attributes to objects
MIT
Allows to attach some attributes to objects
MIT