jclaveau / php-fluent-trait
Traits gathering fluent syntax common methods
Installs: 3 728
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 5
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: 5.*
This package is auto-updated.
Last update: 2024-12-05 12:05:44 UTC
README
These traits gather some commons methods of classes implementing fluent syntax.
Quality
Installation
php-fluent-traits is installable via Composer
composer require jclaveau/php-fluent-traits
Usage
class FluentObject { use JClaveau\Traits\Fluent\New_; use JClaveau\Traits\Fluent\Clone_; use JClaveau\Traits\Fluent\DefineAs; use JClaveau\Traits\Fluent\DefineCloneAs; use JClaveau\Traits\Fluent\Dump; protected $name; public function setName($name) { $this->name = $name; return $this; } } $instance = FluentObject::new_() ->setName('Foo') ->dump() // FluentObject #1 Foo ->defineAs($fooObject1) ->clone_() ->dump() // FluentObject #2 Foo ->defineCloneAs($barObject2) ->setName('Bar') ->dump() // FluentObject #2 Bar ; $fooObject1->dump(); // FluentObject #1 Foo $barObject2->dump(); // FluentObject #3 Foo $instance->dump(); // FluentObject #2 Bar