@@ -29,8 +29,9 @@ |
||
| 29 | 29 | public function getAllRecords() |
| 30 | 30 | { |
| 31 | 31 | $allRecords = $this->allRecords; |
| 32 | - foreach ($allRecords() as $recordData) |
|
| 33 | - yield $recordData; |
|
| 32 | + foreach ($allRecords() as $recordData) { |
|
| 33 | + yield $recordData; |
|
| 34 | + } |
|
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | /** @return Record */ |
@@ -21,8 +21,7 @@ |
||
| 21 | 21 | public function generateSnapshot() { return $this->snapshotColumnName !== null; } |
| 22 | 22 | public function getSnapshotColumnName() { return $this->snapshotColumnName; } |
| 23 | 23 | |
| 24 | - public function __construct |
|
| 25 | - ( |
|
| 24 | + public function __construct( |
|
| 26 | 25 | $name, |
| 27 | 26 | ReadModelId $id, |
| 28 | 27 | array $fields, |
@@ -12,8 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($totalDigits, $fractionalDigits) |
| 14 | 14 | { |
| 15 | - if ($totalDigits <= $fractionalDigits) |
|
| 16 | - throw new \InvalidArgumentException("'totalDigits' ({$totalDigits}) has to be larger than 'fractionalDigits' ({$fractionalDigits})"); |
|
| 15 | + if ($totalDigits <= $fractionalDigits) { |
|
| 16 | + throw new \InvalidArgumentException("'totalDigits' ({$totalDigits}) has to be larger than 'fractionalDigits' ({$fractionalDigits})"); |
|
| 17 | + } |
|
| 17 | 18 | |
| 18 | 19 | $this->totalDigits = $totalDigits; |
| 19 | 20 | $this->fractionalDigits = $fractionalDigits; |
@@ -16,8 +16,7 @@ |
||
| 16 | 16 | private $idColumnName; |
| 17 | 17 | private $columnFactory; |
| 18 | 18 | |
| 19 | - public function __construct |
|
| 20 | - ( |
|
| 19 | + public function __construct( |
|
| 21 | 20 | AbstractSchemaManager $schemaManager, |
| 22 | 21 | Comparator $schemaComparator, |
| 23 | 22 | NameGenerator $tableNameGenerator, |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $this->updateTable($table); |
| 43 | 43 | |
| 44 | - if (!$metadata->generateSnapshot()) return; |
|
| 44 | + if (!$metadata->generateSnapshot()) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | $table = $this->generateTable($metadata, true); |
| 47 | 49 | $table->setPrimaryKey([$this->idColumnName, $metadata->getSnapshotColumnName()]); |
@@ -64,7 +66,9 @@ discard block |
||
| 64 | 66 | |
| 65 | 67 | return new Table($name, |
| 66 | 68 | array_merge($predefinedColumns, array_map(function(ReadModelField $field) use (&$indices) { |
| 67 | - if ($field->useIndex()) $indices[] = new Index(sprintf('IDX_%s', $field->getId()), [$field->getId()]); |
|
| 69 | + if ($field->useIndex()) { |
|
| 70 | + $indices[] = new Index(sprintf('IDX_%s', $field->getId()), [$field->getId()]); |
|
| 71 | + } |
|
| 68 | 72 | |
| 69 | 73 | return $this->columnFactory->createColumn($field->getDataType(), $field->getId()); |
| 70 | 74 | }, $metadata->getFields())), |
@@ -79,13 +83,15 @@ discard block |
||
| 79 | 83 | function(Table $existingTable) use ($table) { return $table->getName() == $existingTable->getName(); } |
| 80 | 84 | ); |
| 81 | 85 | |
| 82 | - if (count($existingTables) > 1) |
|
| 83 | - throw new \UnexpectedValueException(sprintf("Multiple tables with the name '%s' exist.", $table->getName())); |
|
| 86 | + if (count($existingTables) > 1) { |
|
| 87 | + throw new \UnexpectedValueException(sprintf("Multiple tables with the name '%s' exist.", $table->getName())); |
|
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | if (count($existingTables) == 1) { |
| 86 | 91 | $tableDiff = $this->schemaComparator->diffTable(current($existingTables), $table); |
| 87 | - if ($tableDiff) |
|
| 88 | - $this->schemaManager->alterTable($tableDiff); |
|
| 92 | + if ($tableDiff) { |
|
| 93 | + $this->schemaManager->alterTable($tableDiff); |
|
| 94 | + } |
|
| 89 | 95 | } else { |
| 90 | 96 | $this->schemaManager->createTable($table); |
| 91 | 97 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!($loader = include __DIR__ . '/../vendor/autoload.php')) { |
|
| 3 | +if (!($loader = include __DIR__.'/../vendor/autoload.php')) { |
|
| 4 | 4 | die(<<<EOT |
| 5 | 5 | You need to install the project dependencies using Composer: |
| 6 | 6 | $ wget http://getcomposer.org/composer.phar |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function registerContainerConfiguration(LoaderInterface $loader) |
| 19 | 19 | { |
| 20 | - new \PDO('sqlite:' . __DIR__ . '/sqlite.db'); |
|
| 21 | - $loader->load(__DIR__ . '/config.yml'); |
|
| 20 | + new \PDO('sqlite:'.__DIR__.'/sqlite.db'); |
|
| 21 | + $loader->load(__DIR__.'/config.yml'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function build(ContainerBuilder $container) |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function generate($id) |
| 17 | 17 | { |
| 18 | - return $this->prefix . (string) $id; |
|
| 18 | + return $this->prefix.(string) $id; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function generateWithSuffix($id) |
| 22 | 22 | { |
| 23 | - return $this->generate($id) . $this->suffix; |
|
| 23 | + return $this->generate($id).$this->suffix; |
|
| 24 | 24 | } |
| 25 | 25 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public static function setUpBeforeClass() |
| 25 | 25 | { |
| 26 | - unlink(__DIR__ . '/Config/sqlite.db'); |
|
| 26 | + unlink(__DIR__.'/Config/sqlite.db'); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function setUp() |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | new ReadModelField('f1', new Boolean()), |
| 44 | 44 | new ReadModelField('f2', new TextString(10)), |
| 45 | 45 | ], |
| 46 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 47 | - function () {} |
|
| 46 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 47 | + function() {} |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | $this->writer->writeRecord($meta, ['id' => 1, 'f1' => true, 'f2' => 'test']); |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | [ |
| 63 | 63 | new ReadModelField('f1', new TextString(10), true), |
| 64 | 64 | ], |
| 65 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1']]); }, |
|
| 66 | - function () {} |
|
| 65 | + function($data) { return new Record($data['id'], ['f1' => $data['f1']]); }, |
|
| 66 | + function() {} |
|
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | $this->writer->writeRecord($meta, ['id' => 1, 'f1' => 'test']); |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | new ReadModelField('f2', new TextString(10)), |
| 83 | 83 | new ReadModelField('f3', new TextString(10)), |
| 84 | 84 | ], |
| 85 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2'], 'f3' => $data['f2']]); }, |
|
| 86 | - function () {} |
|
| 85 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2'], 'f3' => $data['f2']]); }, |
|
| 86 | + function() {} |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | $this->writer->writeRecord($meta, ['id' => 2, 'f1' => true, 'f2' => 'test']); |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | new ReadModelField('f1', new Boolean()), |
| 103 | 103 | new ReadModelField('f2', new TextString(10)) |
| 104 | 104 | ], |
| 105 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 106 | - function () {} |
|
| 105 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 106 | + function() {} |
|
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | 109 | $this->writer->writeRecord($meta, ['id' => 2, 'f1' => true, 'f2' => 'test2']); |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | new ReadModelField('f1', new Boolean()), |
| 123 | 123 | new ReadModelField('f2', new TextString(10)), |
| 124 | 124 | ], |
| 125 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 126 | - function () {}, |
|
| 125 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
| 126 | + function() {}, |
|
| 127 | 127 | 'created_at' |
| 128 | 128 | ); |
| 129 | 129 | |
@@ -19,8 +19,7 @@ discard block |
||
| 19 | 19 | private $idColumnName; |
| 20 | 20 | private $dbalTypeMapper; |
| 21 | 21 | |
| 22 | - public function __construct |
|
| 23 | - ( |
|
| 22 | + public function __construct( |
|
| 24 | 23 | Connection $connection, |
| 25 | 24 | SchemaSynchronizer $tableGenerator, |
| 26 | 25 | NameGenerator $tableNameGenerator, |
@@ -48,7 +47,7 @@ discard block |
||
| 48 | 47 | $rowData = array_merge([$this->idColumnName => $record->getId()], $record->getData()); |
| 49 | 48 | |
| 50 | 49 | $idType = $this->dbalTypeMapper->mapReadModelToDbalType($metadata->getId()->getDataType()); |
| 51 | - $types = array_merge([$idType], array_map(function (ReadModelField $field) { |
|
| 50 | + $types = array_merge([$idType], array_map(function(ReadModelField $field) { |
|
| 52 | 51 | return $this->dbalTypeMapper->mapReadModelToDbalType($field->getDataType()); |
| 53 | 52 | }, $metadata->getFields())); |
| 54 | 53 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | $container->setParameter('rapido.id_column_name', $config['id_column_name']); |
| 19 | 19 | $container->setAlias('rapido.database_connection', $config['database_connection']); |
| 20 | 20 | |
| 21 | - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 21 | + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 22 | 22 | $loader->load('services.xml'); |
| 23 | 23 | } |
| 24 | 24 | |