Skip to content

Commit

Permalink
Rename EightPointsGuzzleBundlePlugin to follow PSR
Browse files Browse the repository at this point in the history
  • Loading branch information
gregurco committed Oct 8, 2019
1 parent 9ed3ed9 commit 8598fbe
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Configuration implements ConfigurationInterface
protected $debug;

/**
* @var \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin[]
* @var \EightPoints\Bundle\GuzzleBundle\PluginInterface[]
*/
protected $plugins;

Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/EightPointsGuzzleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

class EightPointsGuzzleExtension extends Extension
{
/** @var \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin[] */
/** @var \EightPoints\Bundle\GuzzleBundle\PluginInterface[] */
protected $plugins;

/**
* @param \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin[] $plugins
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface[] $plugins
*/
public function __construct(array $plugins = [])
{
Expand Down
12 changes: 6 additions & 6 deletions src/EightPointsGuzzleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

class EightPointsGuzzleBundle extends Bundle
{
/** @var \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin[] */
/** @var \EightPoints\Bundle\GuzzleBundle\PluginInterface[] */
protected $plugins = [];

/**
* @param \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin[] $plugins
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface[] $plugins
*/
public function __construct(array $plugins = [])
{
Expand Down Expand Up @@ -69,13 +69,13 @@ public function boot()
}

/**
* @param \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin $plugin
*
* @throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @param \EightPoints\Bundle\GuzzleBundle\PluginInterface $plugin
*
* @return void
*@throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*
*/
protected function registerPlugin(EightPointsGuzzleBundlePlugin $plugin)
protected function registerPlugin(PluginInterface $plugin)
{
// Check plugins name duplication
foreach ($this->plugins as $registeredPlugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

interface EightPointsGuzzleBundlePlugin
interface PluginInterface
{
/**
* The name of this plugin. It will be used as the configuration key.
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/doc/how-to-create-a-single-file-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ Create plugin file:
namespace App\GuzzlePlugin;
use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin;
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MagicHeaderPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
class MagicHeaderPlugin extends Bundle implements PluginInterface
{
/**
* @return string
Expand Down Expand Up @@ -147,7 +147,7 @@ class MagicHeaderPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
}
```

Note that we implemented `EightPointsGuzzleBundlePlugin` interface and defined 4 methods:
Note that we implemented `PluginInterface` interface and defined 4 methods:
- `load` - used to load xml/yaml/etc configuration
- `loadForClient` - called after clients services are defined in container builder
- `addConfiguration` - called when configuration tree of Guzzle Bundle is being built
Expand All @@ -158,7 +158,7 @@ First define plugin name:
```php
// ...
class MagicHeaderPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
class MagicHeaderPlugin extends Bundle implements PluginInterface
{
/**
* @return string
Expand All @@ -177,7 +177,7 @@ Next add possibility to configure `header_value` value in configuration file:
```php
// ...
class MagicHeaderPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
class MagicHeaderPlugin extends Bundle implements PluginInterface
{
// ...
Expand Down Expand Up @@ -250,7 +250,7 @@ Having the value of `header_value` option provided from configuration file we ca
use Symfony\Component\ExpressionLanguage\Expression;
use App\GuzzleMiddleware\MagicHeaderMiddleware;
class MagicHeaderPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
class MagicHeaderPlugin extends Bundle implements PluginInterface
{
// ...
Expand Down
6 changes: 3 additions & 3 deletions tests/DependencyInjection/EightPointsGuzzleExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use EightPoints\Bundle\GuzzleBundle\DependencyInjection\Configuration;
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\EightPointsGuzzleExtension;
use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin;
use EightPoints\Bundle\GuzzleBundle\Log\DevNullLogger;
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
Expand Down Expand Up @@ -258,7 +258,7 @@ public function testGetConfiguration()

public function testLoadWithPlugin()
{
$plugin = $this->createMock(EightPointsGuzzleBundlePlugin::class);
$plugin = $this->createMock(PluginInterface::class);
$plugin->method('getPluginName')
->willReturn('test');

Expand Down Expand Up @@ -291,7 +291,7 @@ public function testLoadWithPlugin()

public function testLoadWithoutPlugin()
{
$plugin = $this->createMock(EightPointsGuzzleBundlePlugin::class);
$plugin = $this->createMock(PluginInterface::class);
$plugin->method('getPluginName')
->willReturn('test');

Expand Down
12 changes: 6 additions & 6 deletions tests/EightPointsGuzzleBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\Compiler\EventHandlerCompilerPass;
use EightPoints\Bundle\GuzzleBundle\DependencyInjection\EightPointsGuzzleExtension;
use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle;
use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin;
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -21,7 +21,7 @@ public function testInstance()

public function testInitWithPlugin()
{
$plugin = $this->getMockBuilder(EightPointsGuzzleBundlePlugin::class)->getMock();
$plugin = $this->getMockBuilder(PluginInterface::class)->getMock();

new EightPointsGuzzleBundle([$plugin]);

Expand All @@ -33,12 +33,12 @@ public function testInitWithPluginsNameDuplication()
{
$this->expectException(InvalidConfigurationException::class);

$firstPlugin = $this->getMockBuilder(EightPointsGuzzleBundlePlugin::class)->getMock();
$firstPlugin = $this->getMockBuilder(PluginInterface::class)->getMock();
$firstPlugin->expects($this->once())
->method('getPluginName')
->willReturn('wsse');

$secondPlugin = $this->getMockBuilder(EightPointsGuzzleBundlePlugin::class)->getMock();
$secondPlugin = $this->getMockBuilder(PluginInterface::class)->getMock();
$secondPlugin->expects($this->exactly(2))
->method('getPluginName')
->willReturn('wsse');
Expand All @@ -48,7 +48,7 @@ public function testInitWithPluginsNameDuplication()

public function testBoot()
{
$plugin = $this->getMockBuilder(EightPointsGuzzleBundlePlugin::class)->getMock();
$plugin = $this->getMockBuilder(PluginInterface::class)->getMock();
$plugin->expects($this->once())->method('boot');

$bundle = new EightPointsGuzzleBundle([$plugin]);
Expand All @@ -59,7 +59,7 @@ public function testBuild()
{
$container = new ContainerBuilder();

$plugin = $this->getMockBuilder(EightPointsGuzzleBundlePlugin::class)->getMock();
$plugin = $this->getMockBuilder(PluginInterface::class)->getMock();
$plugin->expects($this->once())->method('build');

$bundle = new EightPointsGuzzleBundle([$plugin]);
Expand Down

0 comments on commit 8598fbe

Please sign in to comment.