These methods return objects on which there are other methods and there are called as well. So getData will return some object that has toArray() method.
You can as well return object itself and use method chaining, i.e.
class MailBuilder {
private $subject;
private$ $body;
public function setSubject($body) {
$this->body = $body;
return $this;
}
public function setBody($body) {
$this->subject = $subject;
return $this;
}
}
and then you could do something like:
$builder = new MailBuilder();
$builder->setSubject('something')->setBody('something');
So you can do that because the methods are returning the object itself and though you can just chain calls to next methods.
Remember that code like that (calling objects nested too deeply) is not good (its called a train wreck):
$object->someMethodReturningObject()->someOtherMethod()->nextObjectMethod()