Skip to content

Instantly share code, notes, and snippets.

@MacDada

MacDada/FooApiClient.php

Last active Mar 27, 2017
Embed
What would you like to do?
<?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