name, surname and salary. Each return the instance of the Employee class allowing to chain methods. class Employee { private string $name; private string $surname; private string $salary; public function setName(string $name) { $this->name = $name; return $this; } public function setSurname(string $surname) { $this->surname = $surname; return $this; } public function setSalary(string $salary) { $this->salary = $salary; return $this; } public function __toString() { $employeeInfo = 'Name: ' . $this->name . PHP_EOL; $employeeInfo .= 'Surname: ' . $this->surname . PHP_EOL; $employeeInfo .= 'Salary: ' . $this->salary . PHP_EOL; return $employeeInfo; } } # Create a new instance of the Employee class, Tom Smith, with a salary of 100: $employee = (new Employee()) ->setName('Tom') ->setSurname('Smith') ->setSalary('100'); # Display the value of the Employee instance: echo $employee; # Display: # Name: Tom # Surname: Smith # Salary: 100 Python In Python, returning self in the instance method is one way to implement the fluent pattern. It is however discouraged by the language’s creator, Guido van Rossum, and therefore considered unpythonic (not idiomatic). class Poem: def __init__(self, title: str) -> None: self.title = title def indent(self, spaces: int): """Indent the poem with the specified number of spaces.""" self.title = " " * spaces + self.title return self def suffix(self, author: str): """Suffix the poem with the author name.""" self.title = f"{self.title} - {author}" return self >>> Poem("Road Not Travelled").indent(4).suffix("Robert Frost").title ' Road Not Travelled - Robert Frost' Swift In Swift 3.0+ returning self in the functions is one way to implement the fluent pattern. class Person { var firstname: String = "" var lastname: String = "" var favoriteQuote: String = "" @discardableResult func set(firstname: String) -> Self { self.firstname = firstname return self } @discardableResult func set(lastname: String) -> Self { self.lastname = lastname return self } @discardableResult func set(favoriteQuote: String) -> Self { self.favoriteQuote = favoriteQuote return self } } let person = Person() .set(firstname: "John") .set(lastname: "Doe") .set(favoriteQuote: "I like turtles") Immutability It's possible to create immutable fluent interfaces that utilise copy-on-write semantics. In this variation of the pattern, instead of modifying internal properties and returning a reference to the same object, the object is instead cloned, with properties changed on the cloned object, and that object returned. The benefit of this approach is that the interface can be used to create configurations of objects that can fork off from a particular point; Allowing two or more objects to