fixes with code inspection

This commit is contained in:
Robin Krahnen 2021-09-21 10:39:03 +02:00
parent 2b15d25ebe
commit 722111191f
4 changed files with 24 additions and 4 deletions

View file

@ -5,7 +5,10 @@ declare(strict_types=1);
namespace DigiComp\Sequence\Command;
use DigiComp\Sequence\Domain\Model\Insert;
use DigiComp\Sequence\Service\Exception as DigiCompSequenceServiceException;
use DigiComp\Sequence\Service\SequenceGenerator;
use Doctrine\DBAL\Driver\Exception as DoctrineDBALDriverException;
use Doctrine\DBAL\Exception as DoctrineDBALException;
use Doctrine\ORM\EntityManagerInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
@ -34,6 +37,7 @@ class SequenceCommandController extends CommandController
*
* @param int $to
* @param string $type
* @throws DigiCompSequenceServiceException
*/
public function advanceCommand(int $to, string $type): void
{
@ -42,6 +46,9 @@ class SequenceCommandController extends CommandController
/**
* @param string[] $typesToClean
* @throws DigiCompSequenceServiceException
* @throws DoctrineDBALDriverException
* @throws DoctrineDBALException
*/
public function cleanSequenceInsertsCommand(array $typesToClean = [])
{

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace DigiComp\Sequence\Service;
use DigiComp\Sequence\Domain\Model\Insert;
use Doctrine\DBAL\Driver\Exception as DoctrineDBALDriverException;
use Doctrine\DBAL\Exception as DoctrineDBALException;
use Doctrine\ORM\EntityManagerInterface;
use Neos\Flow\Annotations as Flow;
@ -37,6 +38,7 @@ class SequenceGenerator
* @param string|object $type
* @return int
* @throws Exception
* @throws DoctrineDBALDriverException
* @throws DoctrineDBALException
*/
public function getNextNumberFor($type): int
@ -71,10 +73,10 @@ class SequenceGenerator
return false;
} catch (DoctrineDBALException $e) {
if (!$e->getPrevious() instanceof \PDOException) {
$this->logger->critical('Exception occured: ' . $e->getMessage());
$this->logger->critical('Exception occurred: ' . $e->getMessage());
}
} catch (\Exception $e) {
$this->logger->critical('Exception occured: ' . $e->getMessage());
$this->logger->critical('Exception occurred: ' . $e->getMessage());
}
return false;
@ -98,6 +100,7 @@ class SequenceGenerator
* @param string|object $type
* @return int
* @throws Exception
* @throws DoctrineDBALDriverException
* @throws DoctrineDBALException
*/
public function getLastNumberFor($type): int
@ -107,7 +110,7 @@ class SequenceGenerator
. $this->entityManager->getClassMetadata(Insert::class)->getTableName()
. ' WHERE type = :type',
['type' => $this->inferTypeFromSource($type)]
)->fetchAll(\PDO::FETCH_COLUMN)[0];
)->fetchOne();
}
/**

View file

@ -2,18 +2,24 @@
namespace DigiComp\Sequence\Tests\Functional;
use DigiComp\Sequence\Service\Exception as DigiCompSequenceServiceException;
use DigiComp\Sequence\Service\SequenceGenerator;
use Doctrine\DBAL\Driver\Exception as DoctrineDBALDriverException;
use Doctrine\DBAL\Exception as DoctrineDBALException;
use Neos\Flow\Tests\FunctionalTestCase;
class SequenceTest extends FunctionalTestCase
{
/**
* @var bool
* @inheritDoc
*/
protected static $testablePersistenceEnabled = true;
/**
* @test
* @throws DigiCompSequenceServiceException
* @throws DoctrineDBALDriverException
* @throws DoctrineDBALException
*/
public function sequenceTest()
{
@ -47,6 +53,9 @@ class SequenceTest extends FunctionalTestCase
/**
* @test
* @throws DigiCompSequenceServiceException
* @throws DoctrineDBALDriverException
* @throws DoctrineDBALException
*/
public function advanceTest()
{

View file

@ -3,6 +3,7 @@
"description": "Sequence is a very simple database agnostic but database based sequence generator",
"type": "neos-package",
"require": {
"ext-pdo": "*",
"neos/flow": "^5.3.0 || ^6.3.5",
"php": "~7.4.0"
},