Skip to content

Commit

Permalink
Added writeGuzzleResponseToFile method
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-bacart committed Jan 30, 2019
1 parent 4ae7e12 commit 669e9aa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ return PhpCsFixer\Config::create()
'fopen_flags' => false,
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
Expand All @@ -45,4 +44,4 @@ return PhpCsFixer\Config::create()
'strict_param' => true,
])
->setFinder($finder)
;
;
17 changes: 17 additions & 0 deletions src/Client/GuzzleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\DomCrawler\Crawler;
use Wa72\HtmlPageDom\HtmlPage;
Expand Down Expand Up @@ -70,6 +71,22 @@ public function getGuzzleResponse(
}
}

/**
* {@inheritdoc}
*
* @throws GuzzleClientException
*/
public function writeGuzzleResponseToFile(
string $uri,
string $filename,
array $options = [],
string $method = self::METHOD_GET
): ResponseInterface {
return $this->getGuzzleResponse($uri, $options + [
RequestOptions::SINK => $filename,
], $method);
}

/**
* {@inheritdoc}
*
Expand Down
15 changes: 15 additions & 0 deletions src/Client/GuzzleClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ public function getGuzzleResponse(
string $method = self::METHOD_GET
): ResponseInterface;

/**
* @param string $uri
* @param string $filename
* @param array $options
* @param string $method
*
* @return ResponseInterface
*/
public function writeGuzzleResponseToFile(
string $uri,
string $filename,
array $options = [],
string $method = self::METHOD_GET
): ResponseInterface;

/**
* @param string $uri
* @param array $options
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/GuzzleMessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GuzzleMessageFormatter extends MessageFormatter
protected const CREDENTIAL_REPLACEMENT = '******';

/** @var string[] */
protected $credentialsToReplace;
protected $credentialsToReplace = [];

/**
* @param string[] $credentialsToReplace
Expand Down

0 comments on commit 669e9aa

Please sign in to comment.