0

The following code is the sample code:

$sample= $module->get('data')
            ->anotherModule
            ->find(true);

I couldn't understand what exactly is the object hierarchy in here. According to my knowledge, there must be an object $module and that class has a method get which takes the parameter as 'data'.

But according to the code, still it gets deeper to anotherModule and find method. Can anyone explain me what is happening in this code?

Ganesh Babu
  • 3,590
  • 11
  • 34
  • 67
  • 1
    its call chaining... you can do this if all method will return some object ex. self [link here](http://stackoverflow.com/questions/3724112/php-method-chaining) – Daredzik Mar 18 '16 at 07:56

1 Answers1

1

This is called method chaining.

A method returns an object which contains other methods. You can find an example for that here: PHP method chaining?

Community
  • 1
  • 1
FlasH
  • 26
  • 3