@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | private $connection; |
22 | 22 | private $config; |
23 | 23 | |
24 | - public function __construct( Connection $connection, TermStoreConfig $config ) { |
|
24 | + public function __construct(Connection $connection, TermStoreConfig $config) { |
|
25 | 25 | $this->connection = $connection; |
26 | 26 | $this->config = $config; |
27 | 27 | } |
@@ -32,35 +32,35 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @throws TermStoreException |
34 | 34 | */ |
35 | - public function storeEntityFingerprint( EntityId $id, Fingerprint $fingerprint ) { |
|
35 | + public function storeEntityFingerprint(EntityId $id, Fingerprint $fingerprint) { |
|
36 | 36 | $this->connection->beginTransaction(); |
37 | 37 | |
38 | - $this->dropTermsForId( $id ); |
|
38 | + $this->dropTermsForId($id); |
|
39 | 39 | |
40 | 40 | try { |
41 | - $this->storeFingerprintParts( $id, $fingerprint ); |
|
41 | + $this->storeFingerprintParts($id, $fingerprint); |
|
42 | 42 | } |
43 | - catch ( DBALException $ex ) { |
|
43 | + catch (DBALException $ex) { |
|
44 | 44 | $this->connection->rollBack(); |
45 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
45 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $this->connection->commit(); |
49 | 49 | } |
50 | 50 | |
51 | - private function storeFingerprintParts( EntityId $id, Fingerprint $fingerprint ) { |
|
51 | + private function storeFingerprintParts(EntityId $id, Fingerprint $fingerprint) { |
|
52 | 52 | /** |
53 | 53 | * @var Term $label |
54 | 54 | */ |
55 | - foreach ( $fingerprint->getLabels() as $label ) { |
|
56 | - $this->storeLabel( $label->getLanguageCode(), $label->getText(), $id ); |
|
55 | + foreach ($fingerprint->getLabels() as $label) { |
|
56 | + $this->storeLabel($label->getLanguageCode(), $label->getText(), $id); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @var AliasGroup $aliasGroup |
61 | 61 | */ |
62 | - foreach ( $fingerprint->getAliasGroups() as $aliasGroup ) { |
|
63 | - $this->storeAliases( $aliasGroup, $id ); |
|
62 | + foreach ($fingerprint->getAliasGroups() as $aliasGroup) { |
|
63 | + $this->storeAliases($aliasGroup, $id); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @throws TermStoreException |
71 | 71 | */ |
72 | - public function dropTermsForId( EntityId $id ) { |
|
72 | + public function dropTermsForId(EntityId $id) { |
|
73 | 73 | try { |
74 | 74 | $this->connection->delete( |
75 | 75 | $this->config->getLabelTableName(), |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | [ 'entity_id' => $id->getSerialization() ] |
82 | 82 | ); |
83 | 83 | } |
84 | - catch ( DBALException $ex ) { |
|
85 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
84 | + catch (DBALException $ex) { |
|
85 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - private function storeLabel( $languageCode, $text, EntityId $id ) { |
|
89 | + private function storeLabel($languageCode, $text, EntityId $id) { |
|
90 | 90 | $this->connection->insert( |
91 | 91 | $this->config->getLabelTableName(), |
92 | 92 | [ |
93 | 93 | 'text' => $text, |
94 | - 'text_lowercase' => strtolower( $text ), |
|
94 | + 'text_lowercase' => strtolower($text), |
|
95 | 95 | 'language' => $languageCode, |
96 | 96 | 'entity_id' => $id->getSerialization(), |
97 | 97 | 'entity_type' => $id->getEntityType() |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | ); |
100 | 100 | } |
101 | 101 | |
102 | - private function storeAliases( AliasGroup $aliasGroup, EntityId $id ) { |
|
103 | - foreach ( $aliasGroup->getAliases() as $alias ) { |
|
102 | + private function storeAliases(AliasGroup $aliasGroup, EntityId $id) { |
|
103 | + foreach ($aliasGroup->getAliases() as $alias) { |
|
104 | 104 | $this->connection->insert( |
105 | 105 | $this->config->getAliasesTableName(), |
106 | 106 | [ |
107 | 107 | 'text' => $alias, |
108 | - 'text_lowercase' => strtolower( $alias ), |
|
108 | + 'text_lowercase' => strtolower($alias), |
|
109 | 109 | 'language' => $aliasGroup->getLanguageCode(), |
110 | 110 | 'entity_id' => $id->getSerialization(), |
111 | 111 | 'entity_type' => $id->getEntityType() |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | try { |
41 | 41 | $this->storeFingerprintParts( $id, $fingerprint ); |
42 | - } |
|
43 | - catch ( DBALException $ex ) { |
|
42 | + } catch ( DBALException $ex ) { |
|
44 | 43 | $this->connection->rollBack(); |
45 | 44 | throw new TermStoreException( $ex->getMessage(), $ex ); |
46 | 45 | } |
@@ -80,8 +79,7 @@ discard block |
||
80 | 79 | $this->config->getAliasesTableName(), |
81 | 80 | [ 'entity_id' => $id->getSerialization() ] |
82 | 81 | ); |
83 | - } |
|
84 | - catch ( DBALException $ex ) { |
|
82 | + } catch ( DBALException $ex ) { |
|
85 | 83 | throw new TermStoreException( $ex->getMessage(), $ex ); |
86 | 84 | } |
87 | 85 | } |
@@ -11,8 +11,8 @@ |
||
11 | 11 | */ |
12 | 12 | class TermStoreException extends \RuntimeException { |
13 | 13 | |
14 | - public function __construct( $message, \Exception $previous = null ) { |
|
15 | - parent::__construct( $message, 0, $previous ); |
|
14 | + public function __construct($message, \Exception $previous = null) { |
|
15 | + parent::__construct($message, 0, $previous); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | private $labelTable; |
16 | 16 | private $aliasesTable; |
17 | 17 | |
18 | - public function __construct( TableQueryExecutor $labelTable, TableQueryExecutor $aliasesTable ) { |
|
18 | + public function __construct(TableQueryExecutor $labelTable, TableQueryExecutor $aliasesTable) { |
|
19 | 19 | $this->labelTable = $labelTable; |
20 | 20 | $this->aliasesTable = $aliasesTable; |
21 | 21 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @return string|null |
30 | 30 | * @throws TermStoreException |
31 | 31 | */ |
32 | - public function getIdByLabel( $labelLanguageCode, $labelText ) { |
|
33 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText ); |
|
32 | + public function getIdByLabel($labelLanguageCode, $labelText) { |
|
33 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return string|null |
43 | 43 | * @throws TermStoreException |
44 | 44 | */ |
45 | - public function getItemIdByLabel( $labelLanguageCode, $labelText ) { |
|
46 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText, 'item' ); |
|
45 | + public function getItemIdByLabel($labelLanguageCode, $labelText) { |
|
46 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText, 'item'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @return string|null |
56 | 56 | * @throws TermStoreException |
57 | 57 | */ |
58 | - public function getPropertyIdByLabel( $labelLanguageCode, $labelText ) { |
|
59 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText, 'property' ); |
|
58 | + public function getPropertyIdByLabel($labelLanguageCode, $labelText) { |
|
59 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText, 'property'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @return string|null |
68 | 68 | * @throws TermStoreException |
69 | 69 | */ |
70 | - private function getEntityIdByLabel( $labelLanguageCode, $labelText, $entityTypeFilter = null ) { |
|
70 | + private function getEntityIdByLabel($labelLanguageCode, $labelText, $entityTypeFilter = null) { |
|
71 | 71 | $conditions = [ |
72 | - 'text_lowercase' => strtolower( $labelText ), |
|
72 | + 'text_lowercase' => strtolower($labelText), |
|
73 | 73 | 'language' => $labelLanguageCode, |
74 | 74 | ]; |
75 | 75 | |
76 | - if ( $entityTypeFilter !== null ) { |
|
77 | - $conditions['entity_type'] = $entityTypeFilter; |
|
76 | + if ($entityTypeFilter !== null) { |
|
77 | + $conditions[ 'entity_type' ] = $entityTypeFilter; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | try { |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $conditions |
84 | 84 | ); |
85 | 85 | } |
86 | - catch ( DBALException $ex ) { |
|
87 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
86 | + catch (DBALException $ex) { |
|
87 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @return string|null |
98 | 98 | * @throws TermStoreException |
99 | 99 | */ |
100 | - public function getIdByText( $languageCode, $termText ) { |
|
101 | - return $this->getEntityIdByText( $languageCode, $termText ); |
|
100 | + public function getIdByText($languageCode, $termText) { |
|
101 | + return $this->getEntityIdByText($languageCode, $termText); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @return string|null |
111 | 111 | * @throws TermStoreException |
112 | 112 | */ |
113 | - public function getItemIdByText( $languageCode, $termText ) { |
|
114 | - return $this->getEntityIdByText( $languageCode, $termText, 'item' ); |
|
113 | + public function getItemIdByText($languageCode, $termText) { |
|
114 | + return $this->getEntityIdByText($languageCode, $termText, 'item'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @return string|null |
124 | 124 | * @throws TermStoreException |
125 | 125 | */ |
126 | - public function getPropertyIdByText( $languageCode, $termText ) { |
|
127 | - return $this->getEntityIdByText( $languageCode, $termText, 'property' ); |
|
126 | + public function getPropertyIdByText($languageCode, $termText) { |
|
127 | + return $this->getEntityIdByText($languageCode, $termText, 'property'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | * @return string|null |
136 | 136 | * @throws TermStoreException |
137 | 137 | */ |
138 | - private function getEntityIdByText( $languageCode, $termText, $entityTypeFilter = null ) { |
|
139 | - $labelMatch = $this->getEntityIdByLabel( $languageCode, $termText, $entityTypeFilter ); |
|
138 | + private function getEntityIdByText($languageCode, $termText, $entityTypeFilter = null) { |
|
139 | + $labelMatch = $this->getEntityIdByLabel($languageCode, $termText, $entityTypeFilter); |
|
140 | 140 | |
141 | - if ( $labelMatch !== null ) { |
|
141 | + if ($labelMatch !== null) { |
|
142 | 142 | return $labelMatch; |
143 | 143 | } |
144 | 144 | |
145 | - return $this->getIdByAlias( $languageCode, $termText, $entityTypeFilter ); |
|
145 | + return $this->getIdByAlias($languageCode, $termText, $entityTypeFilter); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | * @return string|null |
154 | 154 | * @throws TermStoreException |
155 | 155 | */ |
156 | - private function getIdByAlias( $aliasLanguageCode, $aliasText, $entityTypeFilter = null ) { |
|
156 | + private function getIdByAlias($aliasLanguageCode, $aliasText, $entityTypeFilter = null) { |
|
157 | 157 | $conditions = [ |
158 | - 'text_lowercase' => strtolower( $aliasText ), |
|
158 | + 'text_lowercase' => strtolower($aliasText), |
|
159 | 159 | 'language' => $aliasLanguageCode |
160 | 160 | ]; |
161 | 161 | |
162 | - if ( $entityTypeFilter !== null ) { |
|
163 | - $conditions['entity_type'] = $entityTypeFilter; |
|
162 | + if ($entityTypeFilter !== null) { |
|
163 | + $conditions[ 'entity_type' ] = $entityTypeFilter; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | try { |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $conditions |
170 | 170 | ); |
171 | 171 | } |
172 | - catch ( DBALException $ex ) { |
|
173 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
172 | + catch (DBALException $ex) { |
|
173 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | 'entity_id', |
83 | 83 | $conditions |
84 | 84 | ); |
85 | - } |
|
86 | - catch ( DBALException $ex ) { |
|
85 | + } catch ( DBALException $ex ) { |
|
87 | 86 | throw new TermStoreException( $ex->getMessage(), $ex ); |
88 | 87 | } |
89 | 88 | } |
@@ -168,8 +167,7 @@ discard block |
||
168 | 167 | 'entity_id', |
169 | 168 | $conditions |
170 | 169 | ); |
171 | - } |
|
172 | - catch ( DBALException $ex ) { |
|
170 | + } catch ( DBALException $ex ) { |
|
173 | 171 | throw new TermStoreException( $ex->getMessage(), $ex ); |
174 | 172 | } |
175 | 173 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | private $schemaManager; |
20 | 20 | private $config; |
21 | 21 | |
22 | - public function __construct( AbstractSchemaManager $schemaManager, TermStoreConfig $config ) { |
|
22 | + public function __construct(AbstractSchemaManager $schemaManager, TermStoreConfig $config) { |
|
23 | 23 | $this->schemaManager = $schemaManager; |
24 | 24 | $this->config = $config; |
25 | 25 | } |
@@ -28,45 +28,45 @@ discard block |
||
28 | 28 | * @throws DBALException |
29 | 29 | */ |
30 | 30 | public function install() { |
31 | - $this->schemaManager->createTable( $this->newLabelTable() ); |
|
32 | - $this->schemaManager->createTable( $this->newAliasesTable() ); |
|
31 | + $this->schemaManager->createTable($this->newLabelTable()); |
|
32 | + $this->schemaManager->createTable($this->newAliasesTable()); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | private function newLabelTable() { |
36 | - $table = new Table( $this->config->getLabelTableName() ); |
|
36 | + $table = new Table($this->config->getLabelTableName()); |
|
37 | 37 | |
38 | - $table->addColumn( 'text', Type::STRING, array( 'length' => 255 ) ); |
|
39 | - $table->addColumn( 'text_lowercase', Type::STRING, array( 'length' => 255 ) ); |
|
40 | - $table->addColumn( 'language', Type::STRING, array( 'length' => 16 ) ); |
|
41 | - $table->addColumn( 'entity_id', Type::STRING, array( 'length' => 32 ) ); |
|
42 | - $table->addColumn( 'entity_type', Type::STRING, array( 'length' => 16 ) ); |
|
38 | + $table->addColumn('text', Type::STRING, array('length' => 255)); |
|
39 | + $table->addColumn('text_lowercase', Type::STRING, array('length' => 255)); |
|
40 | + $table->addColumn('language', Type::STRING, array('length' => 16)); |
|
41 | + $table->addColumn('entity_id', Type::STRING, array('length' => 32)); |
|
42 | + $table->addColumn('entity_type', Type::STRING, array('length' => 16)); |
|
43 | 43 | |
44 | - $table->addIndex( array( 'text_lowercase', 'language' ) ); |
|
45 | - $table->addIndex( array( 'entity_id', 'language' ) ); |
|
46 | - $table->addIndex( array( 'entity_type' ) ); |
|
44 | + $table->addIndex(array('text_lowercase', 'language')); |
|
45 | + $table->addIndex(array('entity_id', 'language')); |
|
46 | + $table->addIndex(array('entity_type')); |
|
47 | 47 | |
48 | 48 | return $table; |
49 | 49 | } |
50 | 50 | |
51 | 51 | private function newAliasesTable() { |
52 | - $table = new Table( $this->config->getAliasesTableName() ); |
|
52 | + $table = new Table($this->config->getAliasesTableName()); |
|
53 | 53 | |
54 | - $table->addColumn( 'text', Type::STRING, array( 'length' => 255 ) ); |
|
55 | - $table->addColumn( 'text_lowercase', Type::STRING, array( 'length' => 255 ) ); |
|
56 | - $table->addColumn( 'language', Type::STRING, array( 'length' => 16 ) ); |
|
57 | - $table->addColumn( 'entity_id', Type::STRING, array( 'length' => 32 ) ); |
|
58 | - $table->addColumn( 'entity_type', Type::STRING, array( 'length' => 16 ) ); |
|
54 | + $table->addColumn('text', Type::STRING, array('length' => 255)); |
|
55 | + $table->addColumn('text_lowercase', Type::STRING, array('length' => 255)); |
|
56 | + $table->addColumn('language', Type::STRING, array('length' => 16)); |
|
57 | + $table->addColumn('entity_id', Type::STRING, array('length' => 32)); |
|
58 | + $table->addColumn('entity_type', Type::STRING, array('length' => 16)); |
|
59 | 59 | |
60 | - $table->addIndex( array( 'text_lowercase', 'language' ) ); |
|
61 | - $table->addIndex( array( 'entity_id', 'language' ) ); |
|
62 | - $table->addIndex( array( 'entity_type' ) ); |
|
60 | + $table->addIndex(array('text_lowercase', 'language')); |
|
61 | + $table->addIndex(array('entity_id', 'language')); |
|
62 | + $table->addIndex(array('entity_type')); |
|
63 | 63 | |
64 | 64 | return $table; |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function uninstall() { |
68 | - $this->schemaManager->dropTable( $this->config->getLabelTableName() ); |
|
69 | - $this->schemaManager->dropTable( $this->config->getAliasesTableName() ); |
|
68 | + $this->schemaManager->dropTable($this->config->getLabelTableName()); |
|
69 | + $this->schemaManager->dropTable($this->config->getAliasesTableName()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | private $connection; |
17 | 17 | private $config; |
18 | 18 | |
19 | - public function __construct( Connection $connection, TermStoreConfig $config ) { |
|
19 | + public function __construct(Connection $connection, TermStoreConfig $config) { |
|
20 | 20 | $this->connection = $connection; |
21 | 21 | $this->config = $config; |
22 | 22 | } |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * @return EntityIdLookup |
33 | 33 | */ |
34 | 34 | public function newEntityIdLookup() { |
35 | - $labelTable = new TableQueryExecutor( $this->connection, $this->config->getLabelTableName() ); |
|
36 | - $aliasesTable = new TableQueryExecutor( $this->connection, $this->config->getAliasesTableName() ); |
|
35 | + $labelTable = new TableQueryExecutor($this->connection, $this->config->getLabelTableName()); |
|
36 | + $aliasesTable = new TableQueryExecutor($this->connection, $this->config->getAliasesTableName()); |
|
37 | 37 | |
38 | - return new IdLookup( $labelTable, $aliasesTable ); |
|
38 | + return new IdLookup($labelTable, $aliasesTable); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return TermStoreWriter |
43 | 43 | */ |
44 | 44 | public function newTermStoreWriter() { |
45 | - return new TermStoreWriter( $this->connection, $this->config ); |
|
45 | + return new TermStoreWriter($this->connection, $this->config); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return TermStore |
61 | 61 | */ |
62 | 62 | public function newTermStore() { |
63 | - return new TermStore( $this->connection, $this->config ); |
|
63 | + return new TermStore($this->connection, $this->config); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -20,6 +20,6 @@ |
||
20 | 20 | * @return string|null |
21 | 21 | * @throws TermStoreException |
22 | 22 | */ |
23 | - public function getLabelByIdAndLanguage( EntityId $id, $languageCode ); |
|
23 | + public function getLabelByIdAndLanguage(EntityId $id, $languageCode); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | \ No newline at end of file |