n7olkachev / laravel-accessors
Use Laravel-like accessors in your classes
v1.0.0
2017-08-28 19:25 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-11-23 21:51:19 UTC
README
This package gives you ability to use getFooBarAttribute
and setFooBarAttribute
methods in your classes with one trait.
Examples
class User { use Accessors; protected $name; public function __construct($name) { $this->name = $name; } public function getNameAttribute() { return $this->name; } public function setNameAttribute($name) { $this->name = $name; } } $user = new User('Nick'); echo $user->name; // calls getNameAttribute $user->name = 'Not Nick' // calls setNameAttribute
Instalation
$ composer require n7olkachev/laravel-accessors
In your class:
class User { use Accessors; }
Testing
$ composer test
Credits
Sponsored by
Web agency based in Minsk, Belarus
License
The MIT License (MIT)