Download the PHP package wilmoore/attributes.php without Composer
On this page you can find all versions of the php package wilmoore/attributes.php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download wilmoore/attributes.php
More information about wilmoore/attributes.php
Files in wilmoore/attributes.php
Download wilmoore/attributes.php
More information about wilmoore/attributes.php
Files in wilmoore/attributes.php
Vendor wilmoore
Package attributes.php
Short Description minimal object attributes for PHP.
License MIT
Homepage https://github.com/wilmoore/attributes.php
Package attributes.php
Short Description minimal object attributes for PHP.
License MIT
Homepage https://github.com/wilmoore/attributes.php
Please rate this library. Is it a good library?
Informations about the package attributes.php
Attributes Trait for PHP
A minimal trait to decrease getter/setter boilerplate.
Features
- Omit setter/getter methods until needed.
- JSON or Array representation of object attributes.
- Get values via
$object->firstName
or$object->get('firstName')
- Set values via
$object->firstName = 'My Name';
or$object->set('firstName', 'My Name')
isset
,empty
, andunset
work as expected.- Define acceptable input values like
'seconds' => ['accepts' => '0..59']
- Define default values like
'score' => ['default' => 0]
Anti-Features
- Leaning on complex IDEs to produce setter/getter cruft is not a good solution to the underlying problem.
- Leaning on an ORM is not a good solution since not every object in your domain needs to be persisted.
- Leaning on reflection-based meta-programming.
Examples
class Game {
use Attributes;
protected $__attributes = [
'gameName' => [],
'userName' => [],
'score' => ['accepts' => '0..100']
];
}
$game = new Game;
$game->set([
'gameName' => 'pacman',
'userName' => 'manny.pacquiao',
'score' => 95
]);
assert(95 === $game->score);
Installation
Composer
"require": {
"wilmoore/attributes.php": "*"
}
Requirements
- PHP 5.4+
- [optional] PHPUnit 3.6+ to execute the test suite (phpunit --version)
Resources
Changelog
- (0.0.2) 20120726: Added Travis Integration.
- (0.0.1) 20120726: Initial Usable Release.
LICENSE
MIT
All versions of attributes.php with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.4.0
The package wilmoore/attributes.php contains the following files
Loading the files please wait ....