Last active
March 27, 2017 17:22
-
-
Save MacDada/55a8016d686cade546dc02ccf78318bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// singleton | |
class FooApiClient | |
{ | |
private function __construct(); | |
public static function getInstance(): FooApiClient; | |
public function getBar(): Bar; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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