mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-16 10:16:22 +02:00
Formated code
This commit is contained in:
parent
a931d7aebc
commit
6fb99c2f1a
@ -1,24 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ParameterManagement;
|
||||
|
||||
use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface;
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PhpCollection\CollectionInterface;
|
||||
use Doctrine\Migrations\Configuration\Exception\ParameterIncompatibleWithFinder;
|
||||
use PhpParser\ErrorHandler\Collecting;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Infinito\Domain\ParameterManagement\Parameter\AbstractParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
final class ParameterFactory implements ParameterFactoryInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string Namespace under which the parameters are stored
|
||||
*/
|
||||
const PARAMETER_NAMESPACE = 'Infinito\Domain\ParameterManagement\Parameter';
|
||||
@ -28,17 +24,21 @@ final class ParameterFactory implements ParameterFactoryInterface
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
private function initPossible(string $class){
|
||||
if($class === AbstractParameter::class){
|
||||
private function initPossible(string $class)
|
||||
{
|
||||
if (AbstractParameter::class === $class) {
|
||||
return false;
|
||||
}
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
if ($reflectionClass->isInterface()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private function initParameters():void{
|
||||
|
||||
private function initParameters(): void
|
||||
{
|
||||
$this->parameters = new ArrayCollection();
|
||||
$classFinder = new ClassFinder();
|
||||
$parameterClasses = $classFinder->getClassesInNamespace(self::PARAMETER_NAMESPACE);
|
||||
@ -50,13 +50,14 @@ final class ParameterFactory implements ParameterFactoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
$this->initParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* @see \Infinito\Domain\ParameterManagement\ParameterFactoryInterface::getParameter()
|
||||
*/
|
||||
public function getParameter(string $key): ParameterInterface
|
||||
@ -65,11 +66,12 @@ final class ParameterFactory implements ParameterFactoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\ParameterManagement\ParameterFactoryInterface::getAllParameters()
|
||||
*/
|
||||
public function getAllParameters():Collection{
|
||||
public function getAllParameters(): Collection
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ParameterManagement;
|
||||
|
||||
use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface;
|
||||
@ -6,10 +7,9 @@ use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface ParameterFactoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return ParameterInterface
|
||||
*/
|
||||
public function getParameter(string $key): ParameterInterface;
|
||||
@ -19,4 +19,3 @@ interface ParameterFactoryInterface
|
||||
*/
|
||||
public function getAllParameters(): Collection;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
<?php
|
||||
namespace tests\Unit\Domain\ParameterManagement;
|
||||
|
||||
namespace tests\Unit\Domain\ParameterManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\ParameterManagement\ParameterFactory;
|
||||
use Infinito\Domain\ParameterManagement\Parameter\VersionParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
class ParameterFactoryTest extends TestCase
|
||||
{
|
||||
public function testAllParameters():void{
|
||||
public function testAllParameters(): void
|
||||
{
|
||||
$parameterFactory = new ParameterFactory();
|
||||
$allParameters = $parameterFactory->getAllParameters();
|
||||
var_dump($allParameters);
|
||||
@ -22,4 +21,3 @@ class ParameterFactoryTest extends TestCase
|
||||
$this->assertEquals($versionParameter, $parameterFactory->getParameter('version'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user