diff --git a/bin/cli b/bin/cli index 07c906e..e6f3dd3 100644 --- a/bin/cli +++ b/bin/cli @@ -56,5 +56,5 @@ try { } catch (Exception $exception) { echo '[ERROR] Exception ' . $exception->getCode() . ' thrown:' . PHP_EOL; echo $exception->getMessage() . PHP_EOL; - return 1; + exit(1); } diff --git a/src/Configuration.php b/src/Configuration.php index 26ab08c..682752b 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -159,13 +159,13 @@ class Configuration /** * Load and validate configuration settings from YAML file. * - * @throws FileNotFoundException|ValidationFailedException + * @throws FileNotFoundException | ValidationFailedException */ private function __construct() { try { $this->settings = $this->loadConfigFile(); - } catch (FileNotFoundException|ValidationFailedException $exception) { + } catch (FileNotFoundException | ValidationFailedException $exception) { throw $exception; } } diff --git a/src/Console.php b/src/Console.php index c6626e1..7ef0a31 100644 --- a/src/Console.php +++ b/src/Console.php @@ -67,12 +67,14 @@ abstract class Console extends Command if ($limit < 0) { return -1; } - $unit = strtolower($ini[strlen($ini)-1]); - switch($unit) { + $unit = strtolower($ini[strlen($ini) - 1]); + switch ($unit) { case 'g': $limit *= 1024; + // no break case 'm': $limit *= 1024; + // no break case 'k': $limit *= 1024; } diff --git a/src/Console/AddRecordCommand.php b/src/Console/AddRecordCommand.php index 01121c8..b949033 100644 --- a/src/Console/AddRecordCommand.php +++ b/src/Console/AddRecordCommand.php @@ -91,7 +91,9 @@ class AddRecordCommand extends Console /** @var string */ $identifier = $input->getArgument('identifier'); /** @var Format */ - $format = Database::getInstance()->getEntityManager()->getReference(Format::class, $input->getArgument('format')); + $format = Database::getInstance() + ->getEntityManager() + ->getReference(Format::class, $input->getArgument('format')); /** @var string */ $file = $input->getArgument('file'); /** @var string[] */ @@ -105,7 +107,9 @@ class AddRecordCommand extends Console } foreach ($sets as $set) { /** @var Set */ - $setSpec = Database::getInstance()->getEntityManager()->getReference(Set::class, $set); + $setSpec = Database::getInstance() + ->getEntityManager() + ->getReference(Set::class, $set); $record->addSet($setSpec); } diff --git a/src/Console/CsvImportCommand.php b/src/Console/CsvImportCommand.php index cba0591..5386d97 100644 --- a/src/Console/CsvImportCommand.php +++ b/src/Console/CsvImportCommand.php @@ -125,7 +125,9 @@ class CsvImportCommand extends Console /** @var array */ $arguments = $input->getArguments(); /** @var Format */ - $format = Database::getInstance()->getEntityManager()->getReference(Format::class, $arguments['format']); + $format = Database::getInstance() + ->getEntityManager() + ->getReference(Format::class, $arguments['format']); /** @var bool */ $noValidation = $input->getOption('noValidation'); /** @var resource */ @@ -152,7 +154,9 @@ class CsvImportCommand extends Console $sets = $row[$columns['setColumn']]; foreach (explode(',', $sets) as $set) { /** @var Set */ - $setSpec = Database::getInstance()->getEntityManager()->getReference(Set::class, trim($set)); + $setSpec = Database::getInstance() + ->getEntityManager() + ->getReference(Set::class, trim($set)); $record->addSet($setSpec); } } @@ -164,7 +168,9 @@ class CsvImportCommand extends Console // Flush to database if memory usage reaches 50% or every 10.000 records. if ((memory_get_usage() / $phpMemoryLimit) > 0.5 || ($count % 10000) === 0) { - $progressIndicator->setMessage('Importing... ' . (string) $count . ' records processed. Flushing to database...'); + $progressIndicator->setMessage( + 'Importing... ' . (string) $count . ' records processed. Flushing to database...' + ); Database::getInstance()->flush([Record::class]); } } @@ -211,7 +217,7 @@ class CsvImportCommand extends Console '', sprintf( ' [ERROR] File "%s" does not contain valid CSV. ', - stream_get_meta_data($file)['uri'] + stream_get_meta_data($file)['uri'] ?? 'unknown' ), '' ]); @@ -228,7 +234,7 @@ class CsvImportCommand extends Console '', sprintf( ' [ERROR] File "%s" does not contain valid CSV. ', - stream_get_meta_data($file)['uri'] + stream_get_meta_data($file)['uri'] ?? 'unknown' ), '' ]); diff --git a/src/Console/UpdateFormatsCommand.php b/src/Console/UpdateFormatsCommand.php index dd65bca..98afc42 100644 --- a/src/Console/UpdateFormatsCommand.php +++ b/src/Console/UpdateFormatsCommand.php @@ -56,7 +56,9 @@ class UpdateFormatsCommand extends Console { $formats = Configuration::getInstance()->metadataPrefix; $this->clearResultCache(); - $inDatabase = Database::getInstance()->getMetadataFormats()->getQueryResult(); + $inDatabase = Database::getInstance() + ->getMetadataFormats() + ->getQueryResult(); $added = 0; $deleted = 0; $failure = false; diff --git a/src/Database.php b/src/Database.php index cd6eeb3..be378be 100644 --- a/src/Database.php +++ b/src/Database.php @@ -322,8 +322,7 @@ class Database ?DateTime $from = null, ?DateTime $until = null, ?Set $set = null - ): Result - { + ): Result { $maxRecords = Configuration::getInstance()->maxRecords; $cursor = $counter * $maxRecords; @@ -551,7 +550,7 @@ class Database ) ); $configuration->setSchemaAssetsFilter( - static function(string|AbstractAsset $assetName): bool { + static function (string|AbstractAsset $assetName): bool { if ($assetName instanceof AbstractAsset) { $assetName = $assetName->getName(); } diff --git a/src/Entity.php b/src/Entity.php index 3db7ef7..4e666ea 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -107,8 +107,10 @@ abstract class Entity new Assert\NotBlank() ] ); - if ($violations->count() > 0 - or simplexml_load_string($xml) === false) { + if ( + $violations->count() > 0 + or simplexml_load_string($xml) === false + ) { throw new ValidationFailedException(null, $violations); } return $xml; diff --git a/src/Entity/Set.php b/src/Entity/Set.php index 46b4423..0551f63 100644 --- a/src/Entity/Set.php +++ b/src/Entity/Set.php @@ -201,7 +201,10 @@ class Set extends Entity public function __construct(string $spec, ?string $name = null, string $description = null) { try { - $this->spec = $this->validateRegEx($spec, '/^([A-Za-z0-9\-_\.!~\*\'\(\)])+(:[A-Za-z0-9\-_\.!~\*\'\(\)]+)*$/'); + $this->spec = $this->validateRegEx( + $spec, + '/^([A-Za-z0-9\-_\.!~\*\'\(\)])+(:[A-Za-z0-9\-_\.!~\*\'\(\)]+)*$/' + ); $this->setName($name); $this->setDescription($description); $this->records = new ArrayCollection();