Skip to content

Instantly share code, notes, and snippets.

@MacDada
Last active March 27, 2017 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacDada/55a8016d686cade546dc02ccf78318bd to your computer and use it in GitHub Desktop.
Save MacDada/55a8016d686cade546dc02ccf78318bd to your computer and use it in GitHub Desktop.
<?php
// singleton
class FooApiClient
{
private function __construct();
public static function getInstance(): FooApiClient;
public function getBar(): Bar;
}
<?php
class FooApiConsumer
{
public function doSomethingWithBarFromFooApi(): array
{
// ukryta zależność:
$fooApiClient = FooApiClient::getInstance();
// jak to podmienić, żeby nie robiło prawdziwych żądań do API?
$bar = $fooApiClient->getBar();
return $bar->baz();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment