Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 96 | All time: 9,858 This week: 660 |
Version | License | PHP version | Categories | |||
copy-object-attribut 1.0.0 | MIT/X Consortium ... | 7 | Language, PHP 7 |
Description | Author | |||
This class can copy the values of attributes to another object. Innovation Award
|
Simple helper to copy attributes values with the same name from one object to an other.
composer require deoliveiralucas/copy-object-attributes-values
use CopyObjectAttributesValues\CopyObjectAttributesValues;
class ObjectA {
private $attributeA = 'ObjectA_AttrA';
private $attributeB = 'ObjectA_AttrB';
}
class ObjectB {
private $attributeA = 'ObjectB_AttrA';
private $attributeB = 'ObjectB_AttrB';
private $attributeC = 'ObjectB_AttrC';
}
$objectA = new ObjectA();
$objectB = new ObjectB();
CopyObjectAttributesValues::from($objectA)->to($objectB);
var_dump($objectB);
/*
Output:
class ObjectB#2 (3) {
private $attributeA =>
string(13) "ObjectA_AttrA"
private $attributeB =>
string(13) "ObjectA_AttrB"
private $attributeC =>
string(13) "ObjectB_AttrC"
}
*/
Please see CONTRIBUTING for details.
CopyObjectAttributesValues is released under the MIT License. Please see License File for more information.
Files (14) |
File | Role | Description | ||
---|---|---|---|---|
src (1 file) | ||||
test (1 file, 1 directory) | ||||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
CONTRIBUTING.md | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpcs.xml | Data | Auxiliary data | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (14) | / | test |
File | Role | Description | ||
---|---|---|---|---|
unit (1 file, 1 directory) | ||||
bootstrap.php | Aux. | Auxiliary script |
Files (14) | / | test | / | unit |
File | Role | Description | ||
---|---|---|---|---|
CopyObjectAttributesValuesTest (2 files) | ||||
CopyObjectAttributesValuesTest.php | Class | Class source |
Files (14) | / | test | / | unit | / | CopyObjectAttributesValuesTest |
File | Role | Description |
---|---|---|
ClassForAttributesATest.php | Class | Class source |
ClassForAttributesBTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.