1.2.138. Class Has Fluent Interface¶
Mark a class as such when it contains at least one fluent method. A fluent method is a method that returns $this, for chaining.
<?php
class foo {
private $count = 0;
function a() {
++$this->count;
return $this;
}
function b() {
$this->count += 2;
return $this;
}
function c() {
return $this->count;
}
}
$bar = new foo();
print $bar->a()
->b()
->c();
// display 3 (1 + 2).
?>
See also Fluent interface are evil, The basics of Fluent interfaces in PHP and FluentInterface.
1.2.138.1. Connex PHP features¶
1.2.138.1.1. Specs¶
Short name |
Classes/HasFluentInterface |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
High |
Available in |