for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Knp\FriendlyContexts\Http;
use Http\Client\Common\Plugin;
use Http\Client\Common\PluginClient;
use Http\Client\HttpClient;
use Http\Discovery\HttpClientDiscovery;
final class ClientFactory
{
/**
* @var HttpClient
*/
private $client;
private $originalClient;
* @var Plugin[]
private $plugins;
* @var bool
private $clientChanged;
public function __construct(HttpClient $client = null)
$this->originalClient = $client ?: HttpClientDiscovery::find();
$this->client = $this->originalClient;
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$this->resetPlugins();
}
* Drop all registered plugins
public function resetPlugins()
$this->plugins = [new Plugin\ErrorPlugin()];
$this->clientChanged = true;
* Adds a new httplug plugin
*
* @param Plugin $plugin
* @return ClientFactory
public function addPlugin(Plugin $plugin)
$this->plugins[] = $plugin;
return $this;
* @return HttpClient
public function getClient()
if (!$this->clientChanged) {
return $this->client;
return new PluginClient($this->originalClient, $this->plugins);
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.