Skip to content

Commit

Permalink
Apply ECS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Jan 21, 2019
1 parent c921422 commit 93da8e2
Show file tree
Hide file tree
Showing 62 changed files with 243 additions and 638 deletions.
12 changes: 4 additions & 8 deletions src/Builder/BuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Builder;

use SitemapPlugin\Provider\UrlProviderInterface;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
interface BuilderInterface
{
/**
* @param UrlProviderInterface $provider
*/
public function addProvider(UrlProviderInterface $provider): void;
}
}
25 changes: 6 additions & 19 deletions src/Builder/SitemapBuilder.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Builder;

use SitemapPlugin\Factory\SitemapFactoryInterface;
use SitemapPlugin\Model\SitemapInterface;
use SitemapPlugin\Provider\UrlProviderInterface;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
final class SitemapBuilder implements SitemapBuilderInterface
{
/**
* @var SitemapFactoryInterface
*/
/** @var SitemapFactoryInterface */
private $sitemapFactory;

/**
* @var array
*/
/** @var array */
private $providers = [];

/**
* @param SitemapFactoryInterface $sitemapFactory
*/
public function __construct(SitemapFactoryInterface $sitemapFactory)
{
$this->sitemapFactory = $sitemapFactory;
Expand Down Expand Up @@ -63,17 +54,13 @@ public function build(array $filter = []): SitemapInterface
return $sitemap;
}

/**
* @param array $filter
* @return array
*/
private function filter(array $filter): array
{
if (empty($filter)) {
return $this->providers;
}

return array_filter($this->providers, function(UrlProviderInterface $provider) use ($filter) {
return array_filter($this->providers, function (UrlProviderInterface $provider) use ($filter) {
return in_array($provider->getName(), $filter);
});
}
Expand Down
11 changes: 3 additions & 8 deletions src/Builder/SitemapBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Builder;

use SitemapPlugin\Model\SitemapInterface;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
interface SitemapBuilderInterface extends BuilderInterface
{
/**
* @return SitemapInterface
*/
public function build(array $filter = []): SitemapInterface;

/**
Expand Down
22 changes: 6 additions & 16 deletions src/Builder/SitemapIndexBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Builder;

Expand All @@ -7,29 +9,17 @@
use SitemapPlugin\Provider\IndexUrlProviderInterface;
use SitemapPlugin\Provider\UrlProviderInterface;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
final class SitemapIndexBuilder implements SitemapIndexBuilderInterface
{
/**
* @var SitemapIndexFactoryInterface
*/
/** @var SitemapIndexFactoryInterface */
private $sitemapIndexFactory;

/**
* @var array
*/
/** @var array */
private $providers = [];

/**
* @var array
*/
/** @var array */
private $indexProviders = [];

/**
* @param SitemapIndexFactoryInterface $sitemapIndexFactory
*/
public function __construct(SitemapIndexFactoryInterface $sitemapIndexFactory)
{
$this->sitemapIndexFactory = $sitemapIndexFactory;
Expand Down
13 changes: 3 additions & 10 deletions src/Builder/SitemapIndexBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Builder;

use SitemapPlugin\Model\SitemapInterface;
use SitemapPlugin\Provider\IndexUrlProviderInterface;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
interface SitemapIndexBuilderInterface extends BuilderInterface
{
/**
* @param IndexUrlProviderInterface $provider
*/
public function addIndexProvider(IndexUrlProviderInterface $provider): void;

/**
* @return SitemapInterface
*/
public function build(): SitemapInterface;
}
16 changes: 4 additions & 12 deletions src/Controller/AbstractController.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Controller;

use SitemapPlugin\Model\SitemapInterface;
use SitemapPlugin\Renderer\SitemapRendererInterface;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
abstract class AbstractController
{
/**
* @var SitemapRendererInterface
*/
/** @var SitemapRendererInterface */
protected $sitemapRenderer;

/**
* @param SitemapInterface $sitemap
* @return Response
*/
protected function createResponse(SitemapInterface $sitemap): Response
{
$response = new Response($this->sitemapRenderer->render($sitemap));
Expand Down
19 changes: 4 additions & 15 deletions src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Controller;

Expand All @@ -7,21 +9,11 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
class SitemapController extends AbstractController
{
/**
* @var SitemapBuilderInterface
*/
/** @var SitemapBuilderInterface */
protected $sitemapBuilder;

/**
* @param SitemapRendererInterface $sitemapRenderer
* @param SitemapBuilderInterface $sitemapBuilder
*/
public function __construct(
SitemapRendererInterface $sitemapRenderer,
SitemapBuilderInterface $sitemapBuilder
Expand All @@ -30,9 +22,6 @@ public function __construct(
$this->sitemapBuilder = $sitemapBuilder;
}

/**
* @return Response
*/
public function showAction(Request $request): Response
{
$filter = [];
Expand Down
19 changes: 4 additions & 15 deletions src/Controller/SitemapIndexController.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Controller;

use SitemapPlugin\Builder\SitemapIndexBuilderInterface;
use SitemapPlugin\Renderer\SitemapRendererInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
class SitemapIndexController extends AbstractController
{
/**
* @var SitemapIndexBuilderInterface
*/
/** @var SitemapIndexBuilderInterface */
protected $sitemapBuilder;

/**
* @param SitemapRendererInterface $sitemapRenderer
* @param SitemapIndexBuilderInterface $sitemapIndexBuilder
*/
public function __construct(
SitemapRendererInterface $sitemapRenderer,
SitemapIndexBuilderInterface $sitemapIndexBuilder
Expand All @@ -29,9 +21,6 @@ public function __construct(
$this->sitemapBuilder = $sitemapIndexBuilder;
}

/**
* @return Response
*/
public function showAction(): Response
{
return $this->createResponse($this->sitemapBuilder->build());
Expand Down
8 changes: 3 additions & 5 deletions src/DependencyInjection/Compiler/SitemapProviderPass.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
final class SitemapProviderPass implements CompilerPassInterface
{
/**
Expand Down
10 changes: 3 additions & 7 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
final class Configuration implements ConfigurationInterface
{
/**
Expand All @@ -24,9 +23,6 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

/**
* @param ArrayNodeDefinition $node
*/
private function addSitemapSection(ArrayNodeDefinition $node): void
{
$node
Expand Down
8 changes: 3 additions & 5 deletions src/DependencyInjection/SitemapExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\DependencyInjection;

Expand All @@ -7,9 +9,6 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
final class SitemapExtension extends Extension
{
/**
Expand All @@ -23,7 +22,6 @@ public function load(array $config, ContainerBuilder $container)
}
$config = $this->processConfiguration($configuration, $config);


$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');

Expand Down
7 changes: 3 additions & 4 deletions src/Exception/RouteExistsException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Exception;

/**
* @author Stefan Doorn <stefan@efectos.nl>
*/
class RouteExistsException extends \Exception
{
/**
Expand Down
8 changes: 3 additions & 5 deletions src/Exception/SitemapUrlNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace SitemapPlugin\Exception;

use SitemapPlugin\Model\SitemapUrlInterface;

/**
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
* @author Stefan Doorn <stefan@efectos.nl>
*/
class SitemapUrlNotFoundException extends \Exception
{
/**
Expand Down

0 comments on commit 93da8e2

Please sign in to comment.