1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-10-01 00:16:42 +02:00

Merge pull request #65 from alexislefebvre/patch-1

Restrict Method chaining to setters
This commit is contained in:
Tomáš Votruba
2017-09-05 18:18:39 +02:00
committed by GitHub

View File

@@ -1543,8 +1543,8 @@ class Manager {
### Use method chaining ### Use method chaining
This pattern is very useful and commonly used it many libraries such This pattern is very useful and commonly used it many libraries such
as PHPUnit and Doctrine. It allows your code to be expressive, and less verbose. as PHPUnit and Doctrine. It allows your code to be expressive, and less verbose.
For that reason, I say, use method chaining and take a look at how clean your code For that reason, use method chaining and take a look at how clean your code
will be. In your class functions, simply return `this` at the end of every function, will be. In your class functions, simply use `return $this` at the end of every `set` function,
and you can chain further class methods onto it. and you can chain further class methods onto it.
**Bad:** **Bad:**