Learn to read source code. On that GitHub page search for "timeout".
It will show you that AbstractClient
has a timeout
property and a setTimeout()
method:
abstract class AbstractClient implements ClientInterface {
// [...]
protected $timeout = 5;
// [...]
public function setTimeout($timeout) {
$this->timeout = $timeout;
}
// [...]
}
Now you should be thinking, "how can I get to that object?". Since you are using the Browser
class, that is where you should start.
Looking at Browser
's constructor, you can see that it sets the client
property to a class that implements ClientInterface
:
public function __construct(ClientInterface $client = null, FactoryInterface $factory = null) {
$this->client = $client ?: new FileGetContents();
$this->factory = $factory ?: new Factory();
}
Since you are not passing any arguments to the constructor it will set the client to an instance of FileGetContents
, which extends AbstractStream
, which in turn extends AbstractClient
(go through the files and see for yourself).
Since the client
property, set in Browser
's constructor, is set to private you will have to find a way of getting to it. Looking through the class you will find this:
public function getClient() { /* ... */ }
Okay. We now know that we can get the client by calling getClient()
. We also know that the client has a setTimeout()
method:
$buzz->getClient()->setTimeout(40);
VoilĂ .