This document discusses how to decouple objects using standard interfaces in PHP. It covers reasons for using interfaces like encapsulation and reuse. It provides examples of implementing interfaces, extending interfaces, and validating interface usage. It also discusses common interface methods, dynamic properties, magic methods, iterators, observers and more standard PHP interfaces.
11. __toString__toString
● Cast an object to string
/**
* Casting the object to string will
*return the last value
* @return string
*/
public function __toString() {
return (string)end($this->_values);
}
23. Functor ExampleFunctor Example
class DatabaseResultDebugger {
private $_startTime = 0;
public function __construct($startTime) {
$this->_startTime = $startTime;
}
public function __invoke($result) {
var_dump(iterator_to_array($result));
var_dump(microtime(TRUE) - $this->_startTime);
}
}