@@ -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 | } |
@@ -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 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | private $idColumnName; |
18 | 18 | private $dbalTypeMapper; |
19 | 19 | |
20 | - public function __construct |
|
21 | - ( |
|
20 | + public function __construct( |
|
22 | 21 | Connection $connection, |
23 | 22 | NameGenerator $tableNameGenerator, |
24 | 23 | $idColumnName, |
@@ -39,7 +38,7 @@ discard block |
||
39 | 38 | $rowData = array_merge([$this->idColumnName => $record->getId()], $record->getData()); |
40 | 39 | |
41 | 40 | $idType = $this->dbalTypeMapper->mapReadModelToDbalType($metadata->getId()->getDataType()); |
42 | - $types = array_merge([$idType], array_map(function (ReadModelField $field) { |
|
41 | + $types = array_merge([$idType], array_map(function(ReadModelField $field) { |
|
43 | 42 | return $this->dbalTypeMapper->mapReadModelToDbalType($field->getDataType()); |
44 | 43 | }, $metadata->getFields())); |
45 | 44 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function setUpBeforeClass() |
29 | 29 | { |
30 | - unlink(__DIR__ . '/Config/sqlite.db'); |
|
30 | + unlink(__DIR__.'/Config/sqlite.db'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | protected function setUp() |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | new ReadModelField('f1', new Boolean()), |
49 | 49 | new ReadModelField('f2', new TextString(10)), |
50 | 50 | ], |
51 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
52 | - function () {} |
|
51 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
52 | + function() {} |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | $this->synchronizer->ensureTableExists($meta); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | [ |
69 | 69 | new ReadModelField('f1', new TextString(10), true), |
70 | 70 | ], |
71 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1']]); }, |
|
72 | - function () {} |
|
71 | + function($data) { return new Record($data['id'], ['f1' => $data['f1']]); }, |
|
72 | + function() {} |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | $this->synchronizer->ensureTableExists($meta); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | new ReadModelField('f2', new TextString(10)), |
90 | 90 | new ReadModelField('f3', new TextString(10)), |
91 | 91 | ], |
92 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2'], 'f3' => $data['f2']]); }, |
|
93 | - function () {} |
|
92 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2'], 'f3' => $data['f2']]); }, |
|
93 | + function() {} |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | $this->synchronizer->ensureTableExists($meta); |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | new ReadModelField('f1', new Boolean()), |
111 | 111 | new ReadModelField('f2', new TextString(10)) |
112 | 112 | ], |
113 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
114 | - function () {} |
|
113 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
114 | + function() {} |
|
115 | 115 | ); |
116 | 116 | |
117 | 117 | $this->synchronizer->ensureTableExists($meta); |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | new ReadModelField('f1', new Boolean()), |
132 | 132 | new ReadModelField('f2', new TextString(10)), |
133 | 133 | ], |
134 | - function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
135 | - function () {}, |
|
134 | + function($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
|
135 | + function() {}, |
|
136 | 136 | 'created_at' |
137 | 137 | ); |
138 | 138 |