for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TomPHP\HalClient\HttpClient;
use TomPHP\HalClient\HttpClient;
use Zend\Diactoros\Response;
final class DummyHttpClient implements HttpClient
{
const METHOD_GET = 'GET';
/** @var array */
private $endpoints = [
self::METHOD_GET => [],
];
/**
* @param string $method
* @param string $url
* @param string $contentType
* @param string $body
*/
public function createEndpoint($method, $url, $contentType, $body)
$this->endpoints[$method][$url] = new Response(
"data://text/plain,$body",
sprintf
$body
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.
// Instead of $x = "foo $bar $baz"; // Better use either $x = "foo " . $bar . " " . $baz; $x = sprintf("foo %s %s", $bar, $baz);
200,
['content-type' => $contentType]
);
}
public function get($url)
return $this->endpoints[self::METHOD_GET][$url];
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.