@@ -30,13 +30,13 @@ |
||
| 30 | 30 | private $factory; |
| 31 | 31 | |
| 32 | 32 | private function __construct() { |
| 33 | - $connection = DriverManager::getConnection( array( |
|
| 33 | + $connection = DriverManager::getConnection(array( |
|
| 34 | 34 | 'driver' => 'pdo_sqlite', |
| 35 | 35 | 'memory' => true, |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - $config = new TermStoreConfig( 'ts_' ); |
|
| 39 | - $this->factory = new TermStoreFactory( $connection, $config ); |
|
| 38 | + $config = new TermStoreConfig('ts_'); |
|
| 39 | + $this->factory = new TermStoreFactory($connection, $config); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function getFactory() { |
@@ -29,236 +29,236 @@ |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function testGivenNotMatchingArgs_getTermByIdAndLanguageReturnsNull() { |
| 32 | - $this->assertNull( $this->store->getLabelByIdAndLanguage( new ItemId( 'Q1337' ), 'en' ) ); |
|
| 32 | + $this->assertNull($this->store->getLabelByIdAndLanguage(new ItemId('Q1337'), 'en')); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function testStoreIdAndFingerprint() { |
| 36 | - $id = new ItemId( 'Q1337' ); |
|
| 36 | + $id = new ItemId('Q1337'); |
|
| 37 | 37 | |
| 38 | 38 | $fingerprint = new Fingerprint(); |
| 39 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 40 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 41 | - $fingerprint->setDescription( 'en', 'en description' ); |
|
| 42 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 39 | + $fingerprint->setLabel('en', 'en label'); |
|
| 40 | + $fingerprint->setLabel('de', 'de label'); |
|
| 41 | + $fingerprint->setDescription('en', 'en description'); |
|
| 42 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 43 | 43 | |
| 44 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 44 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 45 | 45 | |
| 46 | 46 | $this->assertSame( |
| 47 | 47 | 'en label', |
| 48 | - $this->store->getLabelByIdAndLanguage( $id, 'en' ) |
|
| 48 | + $this->store->getLabelByIdAndLanguage($id, 'en') |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | $this->assertSame( |
| 52 | 52 | 'de label', |
| 53 | - $this->store->getLabelByIdAndLanguage( $id, 'de' ) |
|
| 53 | + $this->store->getLabelByIdAndLanguage($id, 'de') |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | $this->assertSame( |
| 57 | 57 | [ 'first en alias', 'second en alias' ], |
| 58 | - $this->store->getAliasesByIdAndLanguage( $id, 'en' ) |
|
| 58 | + $this->store->getAliasesByIdAndLanguage($id, 'en') |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function testGetIdByLabelAndLanguage() { |
| 63 | - $id = new ItemId( 'Q1337' ); |
|
| 63 | + $id = new ItemId('Q1337'); |
|
| 64 | 64 | |
| 65 | 65 | $fingerprint = new Fingerprint(); |
| 66 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 67 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 66 | + $fingerprint->setLabel('en', 'en label'); |
|
| 67 | + $fingerprint->setLabel('de', 'de label'); |
|
| 68 | 68 | |
| 69 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 69 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 70 | 70 | |
| 71 | 71 | $this->assertSame( |
| 72 | 72 | 'Q1337', |
| 73 | - $this->store->getIdByLabel( 'en', 'en label' ) |
|
| 73 | + $this->store->getIdByLabel('en', 'en label') |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function testStoreFingerprintRemovesOldData() { |
| 78 | - $id = new ItemId( 'Q1337' ); |
|
| 78 | + $id = new ItemId('Q1337'); |
|
| 79 | 79 | |
| 80 | 80 | $fingerprint = new Fingerprint(); |
| 81 | - $fingerprint->setLabel( 'en', 'en label' ); |
|
| 82 | - $fingerprint->setLabel( 'de', 'de label' ); |
|
| 83 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 81 | + $fingerprint->setLabel('en', 'en label'); |
|
| 82 | + $fingerprint->setLabel('de', 'de label'); |
|
| 83 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 84 | 84 | |
| 85 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 85 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 86 | 86 | |
| 87 | 87 | $fingerprint = new Fingerprint(); |
| 88 | - $fingerprint->setLabel( 'de', 'new de label' ); |
|
| 88 | + $fingerprint->setLabel('de', 'new de label'); |
|
| 89 | 89 | |
| 90 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 90 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 91 | 91 | |
| 92 | 92 | $this->assertEquals( |
| 93 | 93 | 'new de label', |
| 94 | - $this->store->getLabelByIdAndLanguage( $id, 'de' ) |
|
| 94 | + $this->store->getLabelByIdAndLanguage($id, 'de') |
|
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - $this->assertNull( $this->store->getLabelByIdAndLanguage( $id, 'en' ) ); |
|
| 98 | - $this->assertEmpty( $this->store->getAliasesByIdAndLanguage( $id, 'en' ) ); |
|
| 97 | + $this->assertNull($this->store->getLabelByIdAndLanguage($id, 'en')); |
|
| 98 | + $this->assertEmpty($this->store->getAliasesByIdAndLanguage($id, 'en')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function testGivenNonMatchingArgs_getAliasesReturnsEmptyArray() { |
| 102 | - $this->assertSame( [], $this->store->getAliasesByIdAndLanguage( new ItemId( 'Q1337' ), 'en' ) ); |
|
| 102 | + $this->assertSame([ ], $this->store->getAliasesByIdAndLanguage(new ItemId('Q1337'), 'en')); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function testGetIdByTextReturnsMatchBasedOnLabel() { |
| 106 | - $id = new ItemId( 'Q1337' ); |
|
| 106 | + $id = new ItemId('Q1337'); |
|
| 107 | 107 | |
| 108 | 108 | $fingerprint = new Fingerprint(); |
| 109 | - $fingerprint->setLabel( 'en', 'kittens' ); |
|
| 110 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 109 | + $fingerprint->setLabel('en', 'kittens'); |
|
| 110 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 111 | 111 | |
| 112 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 112 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 113 | 113 | |
| 114 | - $id = new ItemId( 'Q42' ); |
|
| 114 | + $id = new ItemId('Q42'); |
|
| 115 | 115 | |
| 116 | 116 | $fingerprint = new Fingerprint(); |
| 117 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 118 | - $fingerprint->setAliasGroup( 'en', [ 'kittens', 'first en alias' ] ); |
|
| 117 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 118 | + $fingerprint->setAliasGroup('en', [ 'kittens', 'first en alias' ]); |
|
| 119 | 119 | |
| 120 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 120 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 121 | 121 | |
| 122 | 122 | $this->assertSame( |
| 123 | 123 | 'Q1337', |
| 124 | - $this->store->getIdByText( 'en', 'kittens' ) |
|
| 124 | + $this->store->getIdByText('en', 'kittens') |
|
| 125 | 125 | ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function testGetIdByTextReturnsAliasBasedMatchIfNoLabelsMatch() { |
| 129 | - $id = new ItemId( 'Q1337' ); |
|
| 129 | + $id = new ItemId('Q1337'); |
|
| 130 | 130 | |
| 131 | 131 | $fingerprint = new Fingerprint(); |
| 132 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 133 | - $fingerprint->setAliasGroup( 'en', [ 'first en alias', 'second en alias' ] ); |
|
| 132 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 133 | + $fingerprint->setAliasGroup('en', [ 'first en alias', 'second en alias' ]); |
|
| 134 | 134 | |
| 135 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 135 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 136 | 136 | |
| 137 | - $id = new ItemId( 'Q42' ); |
|
| 137 | + $id = new ItemId('Q42'); |
|
| 138 | 138 | |
| 139 | 139 | $fingerprint = new Fingerprint(); |
| 140 | - $fingerprint->setLabel( 'en', 'foobar' ); |
|
| 141 | - $fingerprint->setAliasGroup( 'en', [ 'kittens', 'first en alias' ] ); |
|
| 140 | + $fingerprint->setLabel('en', 'foobar'); |
|
| 141 | + $fingerprint->setAliasGroup('en', [ 'kittens', 'first en alias' ]); |
|
| 142 | 142 | |
| 143 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 143 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 144 | 144 | |
| 145 | 145 | $this->assertSame( |
| 146 | 146 | 'Q42', |
| 147 | - $this->store->getIdByText( 'en', 'kittens' ) |
|
| 147 | + $this->store->getIdByText('en', 'kittens') |
|
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function testByLabelLookupIsCaseInsensitive() { |
| 152 | - $id = new ItemId( 'Q1337' ); |
|
| 152 | + $id = new ItemId('Q1337'); |
|
| 153 | 153 | |
| 154 | 154 | $fingerprint = new Fingerprint(); |
| 155 | - $fingerprint->setLabel( 'en', 'EN label' ); |
|
| 155 | + $fingerprint->setLabel('en', 'EN label'); |
|
| 156 | 156 | |
| 157 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 157 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 158 | 158 | |
| 159 | 159 | $this->assertSame( |
| 160 | 160 | 'Q1337', |
| 161 | - $this->store->getIdByLabel( 'en', 'en LABEL' ) |
|
| 161 | + $this->store->getIdByLabel('en', 'en LABEL') |
|
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function testGetItemIdByLabelReturnsNoPropertyIds() { |
| 166 | - $id = new PropertyId( 'P1337' ); |
|
| 166 | + $id = new PropertyId('P1337'); |
|
| 167 | 167 | |
| 168 | 168 | $fingerprint = new Fingerprint(); |
| 169 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 169 | + $fingerprint->setLabel('en', 'some label'); |
|
| 170 | 170 | |
| 171 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 171 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 172 | 172 | |
| 173 | - $this->assertNull( $this->store->getItemIdByLabel( 'en', 'some label' ) ); |
|
| 173 | + $this->assertNull($this->store->getItemIdByLabel('en', 'some label')); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function testGetPropertyIdByLabelReturnsNoItemIds() { |
| 177 | - $id = new ItemId( 'Q1337' ); |
|
| 177 | + $id = new ItemId('Q1337'); |
|
| 178 | 178 | |
| 179 | 179 | $fingerprint = new Fingerprint(); |
| 180 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 180 | + $fingerprint->setLabel('en', 'some label'); |
|
| 181 | 181 | |
| 182 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 182 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 183 | 183 | |
| 184 | - $this->assertNull( $this->store->getPropertyIdByLabel( 'en', 'some label' ) ); |
|
| 184 | + $this->assertNull($this->store->getPropertyIdByLabel('en', 'some label')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | public function testGetItemIdByLabelReturnsItemIds() { |
| 188 | - $id = new ItemId( 'Q1337' ); |
|
| 188 | + $id = new ItemId('Q1337'); |
|
| 189 | 189 | |
| 190 | 190 | $fingerprint = new Fingerprint(); |
| 191 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 191 | + $fingerprint->setLabel('en', 'some label'); |
|
| 192 | 192 | |
| 193 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 193 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 194 | 194 | |
| 195 | 195 | $this->assertSame( |
| 196 | 196 | 'Q1337', |
| 197 | - $this->store->getItemIdByLabel( 'en', 'some label' ) |
|
| 197 | + $this->store->getItemIdByLabel('en', 'some label') |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public function testGetPropertyIdByLabelReturnsPropertyIds() { |
| 202 | - $id = new PropertyId( 'P1337' ); |
|
| 202 | + $id = new PropertyId('P1337'); |
|
| 203 | 203 | |
| 204 | 204 | $fingerprint = new Fingerprint(); |
| 205 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 205 | + $fingerprint->setLabel('en', 'some label'); |
|
| 206 | 206 | |
| 207 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 207 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 208 | 208 | |
| 209 | 209 | $this->assertSame( |
| 210 | 210 | 'P1337', |
| 211 | - $this->store->getPropertyIdByLabel( 'en', 'some label' ) |
|
| 211 | + $this->store->getPropertyIdByLabel('en', 'some label') |
|
| 212 | 212 | ); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | public function testGetItemIdByTextReturnsNoPropertyIds() { |
| 216 | - $id = new PropertyId( 'P1337' ); |
|
| 216 | + $id = new PropertyId('P1337'); |
|
| 217 | 217 | |
| 218 | 218 | $fingerprint = new Fingerprint(); |
| 219 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 219 | + $fingerprint->setLabel('en', 'some label'); |
|
| 220 | 220 | |
| 221 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 221 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 222 | 222 | |
| 223 | - $this->assertNull( $this->store->getItemIdByText( 'en', 'some label' ) ); |
|
| 223 | + $this->assertNull($this->store->getItemIdByText('en', 'some label')); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public function testGetPropertyIdByTextReturnsNoItemIds() { |
| 227 | - $id = new ItemId( 'Q1337' ); |
|
| 227 | + $id = new ItemId('Q1337'); |
|
| 228 | 228 | |
| 229 | 229 | $fingerprint = new Fingerprint(); |
| 230 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 230 | + $fingerprint->setLabel('en', 'some label'); |
|
| 231 | 231 | |
| 232 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 232 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 233 | 233 | |
| 234 | - $this->assertNull( $this->store->getPropertyIdByText( 'en', 'some label' ) ); |
|
| 234 | + $this->assertNull($this->store->getPropertyIdByText('en', 'some label')); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | public function testGetItemIdByTextReturnsItemIds() { |
| 238 | - $id = new ItemId( 'Q1337' ); |
|
| 238 | + $id = new ItemId('Q1337'); |
|
| 239 | 239 | |
| 240 | 240 | $fingerprint = new Fingerprint(); |
| 241 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 241 | + $fingerprint->setLabel('en', 'some label'); |
|
| 242 | 242 | |
| 243 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 243 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 244 | 244 | |
| 245 | 245 | $this->assertSame( |
| 246 | 246 | 'Q1337', |
| 247 | - $this->store->getItemIdByText( 'en', 'some label' ) |
|
| 247 | + $this->store->getItemIdByText('en', 'some label') |
|
| 248 | 248 | ); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function testGetPropertyIdByTextReturnsPropertyIds() { |
| 252 | - $id = new PropertyId( 'P1337' ); |
|
| 252 | + $id = new PropertyId('P1337'); |
|
| 253 | 253 | |
| 254 | 254 | $fingerprint = new Fingerprint(); |
| 255 | - $fingerprint->setLabel( 'en', 'some label' ); |
|
| 255 | + $fingerprint->setLabel('en', 'some label'); |
|
| 256 | 256 | |
| 257 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 257 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 258 | 258 | |
| 259 | 259 | $this->assertSame( |
| 260 | 260 | 'P1337', |
| 261 | - $this->store->getPropertyIdByText( 'en', 'some label' ) |
|
| 261 | + $this->store->getPropertyIdByText('en', 'some label') |
|
| 262 | 262 | ); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( PHP_SAPI !== 'cli' ) { |
|
| 4 | - die( 'Not an entry point' ); |
|
| 3 | +if (PHP_SAPI !== 'cli') { |
|
| 4 | + die('Not an entry point'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -error_reporting( E_ALL | E_STRICT ); |
|
| 8 | -ini_set( 'display_errors', 1 ); |
|
| 7 | +error_reporting(E_ALL | E_STRICT); |
|
| 8 | +ini_set('display_errors', 1); |
|
| 9 | 9 | |
| 10 | -if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) { |
|
| 11 | - die( 'You need to install this package with Composer before you can run the tests' ); |
|
| 10 | +if (!is_readable(__DIR__.'/../vendor/autoload.php')) { |
|
| 11 | + die('You need to install this package with Composer before you can run the tests'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -$autoLoader = require __DIR__ . '/../vendor/autoload.php'; |
|
| 14 | +$autoLoader = require __DIR__.'/../vendor/autoload.php'; |
|
| 15 | 15 | |
| 16 | -$autoLoader->addPsr4( 'Tests\\Queryr\\TermStore\\', __DIR__ . '/integration' ); |
|
| 16 | +$autoLoader->addPsr4('Tests\\Queryr\\TermStore\\', __DIR__.'/integration'); |
|
| 17 | 17 | |
| 18 | -unset( $autoLoader ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +unset($autoLoader); |
|
| 20 | 20 | \ No newline at end of file |
@@ -15,70 +15,70 @@ |
||
| 15 | 15 | private $connection; |
| 16 | 16 | private $tableName; |
| 17 | 17 | |
| 18 | - public function __construct( Connection $connection, $tableName ) { |
|
| 18 | + public function __construct(Connection $connection, $tableName) { |
|
| 19 | 19 | $this->connection = $connection; |
| 20 | 20 | $this->tableName = $tableName; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function selectOneField( $fieldName, array $conditions = [] ) { |
|
| 24 | - return $this->selectOne( [ $fieldName ], $conditions )[$fieldName]; |
|
| 23 | + public function selectOneField($fieldName, array $conditions = [ ]) { |
|
| 24 | + return $this->selectOne([ $fieldName ], $conditions)[ $fieldName ]; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function selectOne( array $fieldNames = null, array $conditions = [] ) { |
|
| 28 | - $statement = $this->executeSelect( $fieldNames, $conditions, 1 ); |
|
| 27 | + public function selectOne(array $fieldNames = null, array $conditions = [ ]) { |
|
| 28 | + $statement = $this->executeSelect($fieldNames, $conditions, 1); |
|
| 29 | 29 | |
| 30 | 30 | $result = $statement->fetch(); |
| 31 | 31 | return $result === false ? null : $result; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function select( array $fieldNames = null, array $conditions = [] ) { |
|
| 35 | - $statement = $this->executeSelect( $fieldNames, $conditions ); |
|
| 34 | + public function select(array $fieldNames = null, array $conditions = [ ]) { |
|
| 35 | + $statement = $this->executeSelect($fieldNames, $conditions); |
|
| 36 | 36 | return $statement->fetchAll(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function selectField( $fieldName, array $conditions = [] ) { |
|
| 39 | + public function selectField($fieldName, array $conditions = [ ]) { |
|
| 40 | 40 | return array_map( |
| 41 | - function( array $resultRow ) use ( $fieldName ) { |
|
| 42 | - return $resultRow[$fieldName]; |
|
| 41 | + function(array $resultRow) use ($fieldName) { |
|
| 42 | + return $resultRow[ $fieldName ]; |
|
| 43 | 43 | }, |
| 44 | - $this->select( [ $fieldName ], $conditions ) |
|
| 44 | + $this->select([ $fieldName ], $conditions) |
|
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - private function executeSelect( array $fieldNames = null, array $conditions = [], $limit = null ) { |
|
| 49 | - $sql = $this->buildSelectSql( $fieldNames, $conditions, $limit ); |
|
| 48 | + private function executeSelect(array $fieldNames = null, array $conditions = [ ], $limit = null) { |
|
| 49 | + $sql = $this->buildSelectSql($fieldNames, $conditions, $limit); |
|
| 50 | 50 | |
| 51 | - $statement = $this->connection->prepare( $sql ); |
|
| 52 | - $statement->execute( array_values( $conditions ) ); |
|
| 51 | + $statement = $this->connection->prepare($sql); |
|
| 52 | + $statement->execute(array_values($conditions)); |
|
| 53 | 53 | |
| 54 | 54 | return $statement; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - private function buildSelectSql( array $fieldNames = null, array $conditions = [], $limit = null ) { |
|
| 58 | - $fieldSql = $this->getFieldSql( $fieldNames ); |
|
| 59 | - $conditionSql = $this->getConditionSql( $conditions ); |
|
| 57 | + private function buildSelectSql(array $fieldNames = null, array $conditions = [ ], $limit = null) { |
|
| 58 | + $fieldSql = $this->getFieldSql($fieldNames); |
|
| 59 | + $conditionSql = $this->getConditionSql($conditions); |
|
| 60 | 60 | |
| 61 | - $sql = 'SELECT ' . $fieldSql . ' FROM ' . $this->tableName . ' WHERE ' . $conditionSql; |
|
| 61 | + $sql = 'SELECT '.$fieldSql.' FROM '.$this->tableName.' WHERE '.$conditionSql; |
|
| 62 | 62 | |
| 63 | - if ( $limit !== null ) { |
|
| 64 | - $sql .= ' LIMIT ' . (int)$limit; |
|
| 63 | + if ($limit !== null) { |
|
| 64 | + $sql .= ' LIMIT '.(int)$limit; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $sql; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - private function getFieldSql( array $fields = null ) { |
|
| 71 | - return $fields === null || $fields === [] ? '*' : implode( ', ', (array)$fields ); |
|
| 70 | + private function getFieldSql(array $fields = null) { |
|
| 71 | + return $fields === null || $fields === [ ] ? '*' : implode(', ', (array)$fields); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - private function getConditionSql( array $conditions ) { |
|
| 75 | - $wherePredicates = []; |
|
| 74 | + private function getConditionSql(array $conditions) { |
|
| 75 | + $wherePredicates = [ ]; |
|
| 76 | 76 | |
| 77 | - foreach ( $conditions as $columnName => $columnValue ) { |
|
| 78 | - $wherePredicates[] = $columnName . ' = ?'; |
|
| 77 | + foreach ($conditions as $columnName => $columnValue) { |
|
| 78 | + $wherePredicates[ ] = $columnName.' = ?'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return implode( ' AND ', $wherePredicates ); |
|
| 81 | + return implode(' AND ', $wherePredicates); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | } |
@@ -65,8 +65,7 @@ discard block |
||
| 65 | 65 | 'language' => $languageCode |
| 66 | 66 | ] |
| 67 | 67 | ); |
| 68 | - } |
|
| 69 | - catch ( DBALException $ex ) { |
|
| 68 | + } catch ( DBALException $ex ) { |
|
| 70 | 69 | throw new TermStoreException( $ex->getMessage(), $ex ); |
| 71 | 70 | } |
| 72 | 71 | } |
@@ -87,8 +86,7 @@ discard block |
||
| 87 | 86 | 'language' => $languageCode |
| 88 | 87 | ] |
| 89 | 88 | ); |
| 90 | - } |
|
| 91 | - catch ( DBALException $ex ) { |
|
| 89 | + } catch ( DBALException $ex ) { |
|
| 92 | 90 | throw new TermStoreException( $ex->getMessage(), $ex ); |
| 93 | 91 | } |
| 94 | 92 | } |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | private $labelTable; |
| 23 | 23 | private $aliasesTable; |
| 24 | 24 | |
| 25 | - public function __construct( Connection $connection, TermStoreConfig $config ) { |
|
| 26 | - $this->labelTable = new TableQueryExecutor( $connection, $config->getLabelTableName() ); |
|
| 27 | - $this->aliasesTable = new TableQueryExecutor( $connection, $config->getAliasesTableName() ); |
|
| 25 | + public function __construct(Connection $connection, TermStoreConfig $config) { |
|
| 26 | + $this->labelTable = new TableQueryExecutor($connection, $config->getLabelTableName()); |
|
| 27 | + $this->aliasesTable = new TableQueryExecutor($connection, $config->getAliasesTableName()); |
|
| 28 | 28 | |
| 29 | - $this->storeWriter = new TermStoreWriter( $connection, $config ); |
|
| 30 | - $this->idLookup = new IdLookup( $this->labelTable, $this->aliasesTable ); |
|
| 29 | + $this->storeWriter = new TermStoreWriter($connection, $config); |
|
| 30 | + $this->idLookup = new IdLookup($this->labelTable, $this->aliasesTable); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @throws TermStoreException |
| 38 | 38 | */ |
| 39 | - public function storeEntityFingerprint( EntityId $id, Fingerprint $fingerprint ) { |
|
| 40 | - $this->storeWriter->storeEntityFingerprint( $id, $fingerprint ); |
|
| 39 | + public function storeEntityFingerprint(EntityId $id, Fingerprint $fingerprint) { |
|
| 40 | + $this->storeWriter->storeEntityFingerprint($id, $fingerprint); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @throws TermStoreException |
| 47 | 47 | */ |
| 48 | - public function dropTermsForId( EntityId $id ) { |
|
| 49 | - $this->storeWriter->dropTermsForId( $id ); |
|
| 48 | + public function dropTermsForId(EntityId $id) { |
|
| 49 | + $this->storeWriter->dropTermsForId($id); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @throws TermStoreException |
| 54 | 54 | */ |
| 55 | - public function getLabelByIdAndLanguage( EntityId $id, string $languageCode ): ?string { |
|
| 55 | + public function getLabelByIdAndLanguage(EntityId $id, string $languageCode): ?string { |
|
| 56 | 56 | try { |
| 57 | 57 | return $this->labelTable->selectOneField( |
| 58 | 58 | 'text', |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | ] |
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | - catch ( DBALException $ex ) { |
|
| 66 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
| 65 | + catch (DBALException $ex) { |
|
| 66 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return string[] |
| 75 | 75 | * @throws TermStoreException |
| 76 | 76 | */ |
| 77 | - public function getAliasesByIdAndLanguage( EntityId $id, string $languageCode ): array { |
|
| 77 | + public function getAliasesByIdAndLanguage(EntityId $id, string $languageCode): array { |
|
| 78 | 78 | try { |
| 79 | 79 | return $this->aliasesTable->selectField( |
| 80 | 80 | 'text', |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | ] |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | - catch ( DBALException $ex ) { |
|
| 88 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
| 87 | + catch (DBALException $ex) { |
|
| 88 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @throws TermStoreException |
| 96 | 96 | */ |
| 97 | - public function getIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 98 | - return $this->idLookup->getIdByLabel( $labelLanguageCode, $labelText ); |
|
| 97 | + public function getIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 98 | + return $this->idLookup->getIdByLabel($labelLanguageCode, $labelText); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @throws TermStoreException |
| 105 | 105 | */ |
| 106 | - public function getItemIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 107 | - return $this->idLookup->getItemIdByLabel( $labelLanguageCode, $labelText ); |
|
| 106 | + public function getItemIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 107 | + return $this->idLookup->getItemIdByLabel($labelLanguageCode, $labelText); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @throws TermStoreException |
| 114 | 114 | */ |
| 115 | - public function getPropertyIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 116 | - return $this->idLookup->getPropertyIdByLabel( $labelLanguageCode, $labelText ); |
|
| 115 | + public function getPropertyIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 116 | + return $this->idLookup->getPropertyIdByLabel($labelLanguageCode, $labelText); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @throws TermStoreException |
| 123 | 123 | */ |
| 124 | - public function getIdByText( string $languageCode, string $termText ): ?string { |
|
| 125 | - return $this->idLookup->getIdByText( $languageCode, $termText ); |
|
| 124 | + public function getIdByText(string $languageCode, string $termText): ?string { |
|
| 125 | + return $this->idLookup->getIdByText($languageCode, $termText); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @throws TermStoreException |
| 132 | 132 | */ |
| 133 | - public function getItemIdByText( string $languageCode, string $termText ): ?string { |
|
| 134 | - return $this->idLookup->getItemIdByText( $languageCode, $termText ); |
|
| 133 | + public function getItemIdByText(string $languageCode, string $termText): ?string { |
|
| 134 | + return $this->idLookup->getItemIdByText($languageCode, $termText); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @throws TermStoreException |
| 141 | 141 | */ |
| 142 | - public function getPropertyIdByText( string $languageCode, string $termText ): ?string { |
|
| 143 | - return $this->idLookup->getPropertyIdByText( $languageCode, $termText ); |
|
| 142 | + public function getPropertyIdByText(string $languageCode, string $termText): ?string { |
|
| 143 | + return $this->idLookup->getPropertyIdByText($languageCode, $termText); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | } |
@@ -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 | } |
@@ -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,17 +32,17 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @throws TermStoreException |
| 34 | 34 | */ |
| 35 | - public function storeEntityFingerprint( EntityId $id, Fingerprint $fingerprint ): void { |
|
| 35 | + public function storeEntityFingerprint(EntityId $id, Fingerprint $fingerprint): void { |
|
| 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(); |
@@ -51,19 +51,19 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * @throws DBALException |
| 53 | 53 | */ |
| 54 | - private function storeFingerprintParts( EntityId $id, Fingerprint $fingerprint ) { |
|
| 54 | + private function storeFingerprintParts(EntityId $id, Fingerprint $fingerprint) { |
|
| 55 | 55 | /** |
| 56 | 56 | * @var Term $label |
| 57 | 57 | */ |
| 58 | - foreach ( $fingerprint->getLabels() as $label ) { |
|
| 59 | - $this->storeLabel( $label->getLanguageCode(), $label->getText(), $id ); |
|
| 58 | + foreach ($fingerprint->getLabels() as $label) { |
|
| 59 | + $this->storeLabel($label->getLanguageCode(), $label->getText(), $id); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @var AliasGroup $aliasGroup |
| 64 | 64 | */ |
| 65 | - foreach ( $fingerprint->getAliasGroups() as $aliasGroup ) { |
|
| 66 | - $this->storeAliases( $aliasGroup, $id ); |
|
| 65 | + foreach ($fingerprint->getAliasGroups() as $aliasGroup) { |
|
| 66 | + $this->storeAliases($aliasGroup, $id); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @throws TermStoreException |
| 74 | 74 | */ |
| 75 | - public function dropTermsForId( EntityId $id ): void { |
|
| 75 | + public function dropTermsForId(EntityId $id): void { |
|
| 76 | 76 | try { |
| 77 | 77 | $this->connection->delete( |
| 78 | 78 | $this->config->getLabelTableName(), |
@@ -84,20 +84,20 @@ discard block |
||
| 84 | 84 | [ 'entity_id' => $id->getSerialization() ] |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | - catch ( DBALException $ex ) { |
|
| 88 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
| 87 | + catch (DBALException $ex) { |
|
| 88 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @throws DBALException |
| 94 | 94 | */ |
| 95 | - private function storeLabel( string $languageCode, string $text, EntityId $id ) { |
|
| 95 | + private function storeLabel(string $languageCode, string $text, EntityId $id) { |
|
| 96 | 96 | $this->connection->insert( |
| 97 | 97 | $this->config->getLabelTableName(), |
| 98 | 98 | [ |
| 99 | 99 | 'text' => $text, |
| 100 | - 'text_lowercase' => strtolower( $text ), |
|
| 100 | + 'text_lowercase' => strtolower($text), |
|
| 101 | 101 | 'language' => $languageCode, |
| 102 | 102 | 'entity_id' => $id->getSerialization(), |
| 103 | 103 | 'entity_type' => $id->getEntityType() |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * @throws DBALException |
| 110 | 110 | */ |
| 111 | - private function storeAliases( AliasGroup $aliasGroup, EntityId $id ) { |
|
| 112 | - foreach ( $aliasGroup->getAliases() as $alias ) { |
|
| 111 | + private function storeAliases(AliasGroup $aliasGroup, EntityId $id) { |
|
| 112 | + foreach ($aliasGroup->getAliases() as $alias) { |
|
| 113 | 113 | $this->connection->insert( |
| 114 | 114 | $this->config->getAliasesTableName(), |
| 115 | 115 | [ |
| 116 | 116 | 'text' => $alias, |
| 117 | - 'text_lowercase' => strtolower( $alias ), |
|
| 117 | + 'text_lowercase' => strtolower($alias), |
|
| 118 | 118 | 'language' => $aliasGroup->getLanguageCode(), |
| 119 | 119 | 'entity_id' => $id->getSerialization(), |
| 120 | 120 | 'entity_type' => $id->getEntityType() |
@@ -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 | } |
@@ -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 | } |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @throws TermStoreException |
| 27 | 27 | */ |
| 28 | - public function getIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 29 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText ); |
|
| 28 | + public function getIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 29 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @throws TermStoreException |
| 36 | 36 | */ |
| 37 | - public function getItemIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 38 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText, 'item' ); |
|
| 37 | + public function getItemIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 38 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText, 'item'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @throws TermStoreException |
| 45 | 45 | */ |
| 46 | - public function getPropertyIdByLabel( string $labelLanguageCode, string $labelText ): ?string { |
|
| 47 | - return $this->getEntityIdByLabel( $labelLanguageCode, $labelText, 'property' ); |
|
| 46 | + public function getPropertyIdByLabel(string $labelLanguageCode, string $labelText): ?string { |
|
| 47 | + return $this->getEntityIdByLabel($labelLanguageCode, $labelText, 'property'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * @return string|null |
| 56 | 56 | * @throws TermStoreException |
| 57 | 57 | */ |
| 58 | - private function getEntityIdByLabel( $labelLanguageCode, $labelText, $entityTypeFilter = null ) { |
|
| 58 | + private function getEntityIdByLabel($labelLanguageCode, $labelText, $entityTypeFilter = null) { |
|
| 59 | 59 | $conditions = [ |
| 60 | - 'text_lowercase' => strtolower( $labelText ), |
|
| 60 | + 'text_lowercase' => strtolower($labelText), |
|
| 61 | 61 | 'language' => $labelLanguageCode, |
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | - if ( $entityTypeFilter !== null ) { |
|
| 65 | - $conditions['entity_type'] = $entityTypeFilter; |
|
| 64 | + if ($entityTypeFilter !== null) { |
|
| 65 | + $conditions[ 'entity_type' ] = $entityTypeFilter; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | try { |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | $conditions |
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | - catch ( DBALException $ex ) { |
|
| 75 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
| 74 | + catch (DBALException $ex) { |
|
| 75 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @throws TermStoreException |
| 83 | 83 | */ |
| 84 | - public function getIdByText( string $languageCode, string $termText ): ?string { |
|
| 85 | - return $this->getEntityIdByText( $languageCode, $termText ); |
|
| 84 | + public function getIdByText(string $languageCode, string $termText): ?string { |
|
| 85 | + return $this->getEntityIdByText($languageCode, $termText); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @throws TermStoreException |
| 92 | 92 | */ |
| 93 | - public function getItemIdByText( string $languageCode, string $termText ): ?string { |
|
| 94 | - return $this->getEntityIdByText( $languageCode, $termText, 'item' ); |
|
| 93 | + public function getItemIdByText(string $languageCode, string $termText): ?string { |
|
| 94 | + return $this->getEntityIdByText($languageCode, $termText, 'item'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @throws TermStoreException |
| 101 | 101 | */ |
| 102 | - public function getPropertyIdByText( string $languageCode, string $termText ): ?string { |
|
| 103 | - return $this->getEntityIdByText( $languageCode, $termText, 'property' ); |
|
| 102 | + public function getPropertyIdByText(string $languageCode, string $termText): ?string { |
|
| 103 | + return $this->getEntityIdByText($languageCode, $termText, 'property'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | * @return string|null |
| 112 | 112 | * @throws TermStoreException |
| 113 | 113 | */ |
| 114 | - private function getEntityIdByText( string $languageCode, string $termText, $entityTypeFilter = null ) { |
|
| 115 | - $labelMatch = $this->getEntityIdByLabel( $languageCode, $termText, $entityTypeFilter ); |
|
| 114 | + private function getEntityIdByText(string $languageCode, string $termText, $entityTypeFilter = null) { |
|
| 115 | + $labelMatch = $this->getEntityIdByLabel($languageCode, $termText, $entityTypeFilter); |
|
| 116 | 116 | |
| 117 | - if ( $labelMatch !== null ) { |
|
| 117 | + if ($labelMatch !== null) { |
|
| 118 | 118 | return $labelMatch; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return $this->getIdByAlias( $languageCode, $termText, $entityTypeFilter ); |
|
| 121 | + return $this->getIdByAlias($languageCode, $termText, $entityTypeFilter); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * @return string|null |
| 130 | 130 | * @throws TermStoreException |
| 131 | 131 | */ |
| 132 | - private function getIdByAlias( string $aliasLanguageCode, string $aliasText, $entityTypeFilter = null ) { |
|
| 132 | + private function getIdByAlias(string $aliasLanguageCode, string $aliasText, $entityTypeFilter = null) { |
|
| 133 | 133 | $conditions = [ |
| 134 | - 'text_lowercase' => strtolower( $aliasText ), |
|
| 134 | + 'text_lowercase' => strtolower($aliasText), |
|
| 135 | 135 | 'language' => $aliasLanguageCode |
| 136 | 136 | ]; |
| 137 | 137 | |
| 138 | - if ( $entityTypeFilter !== null ) { |
|
| 139 | - $conditions['entity_type'] = $entityTypeFilter; |
|
| 138 | + if ($entityTypeFilter !== null) { |
|
| 139 | + $conditions[ 'entity_type' ] = $entityTypeFilter; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | try { |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | $conditions |
| 146 | 146 | ); |
| 147 | 147 | } |
| 148 | - catch ( DBALException $ex ) { |
|
| 149 | - throw new TermStoreException( $ex->getMessage(), $ex ); |
|
| 148 | + catch (DBALException $ex) { |
|
| 149 | + throw new TermStoreException($ex->getMessage(), $ex); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
@@ -28,15 +28,15 @@ |
||
| 28 | 28 | public function testWhenNoConnection_storeEntityFingerprintThrowsException() { |
| 29 | 29 | $writer = TestEnvironment::newInstanceWithoutTables()->getFactory()->newTermStoreWriter(); |
| 30 | 30 | |
| 31 | - $this->expectException( TermStoreException::class ); |
|
| 32 | - $writer->storeEntityFingerprint( new ItemId( 'Q1' ), new Fingerprint() ); |
|
| 31 | + $this->expectException(TermStoreException::class); |
|
| 32 | + $writer->storeEntityFingerprint(new ItemId('Q1'), new Fingerprint()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function testWhenNoConnection_dropTermsForIdThrowsException() { |
| 36 | 36 | $writer = TestEnvironment::newInstanceWithoutTables()->getFactory()->newTermStoreWriter(); |
| 37 | 37 | |
| 38 | - $this->expectException( TermStoreException::class ); |
|
| 39 | - $writer->dropTermsForId( new ItemId( 'Q1' ) ); |
|
| 38 | + $this->expectException(TermStoreException::class); |
|
| 39 | + $writer->dropTermsForId(new ItemId('Q1')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | } |
@@ -24,22 +24,22 @@ |
||
| 24 | 24 | private $store; |
| 25 | 25 | |
| 26 | 26 | public function setUp() { |
| 27 | - $connection = DriverManager::getConnection( array( |
|
| 27 | + $connection = DriverManager::getConnection(array( |
|
| 28 | 28 | 'driver' => 'pdo_sqlite', |
| 29 | 29 | 'memory' => true, |
| 30 | - ) ); |
|
| 30 | + )); |
|
| 31 | 31 | |
| 32 | - $this->store = new TermStore( $connection, new TermStoreConfig( '' ) ); |
|
| 32 | + $this->store = new TermStore($connection, new TermStoreConfig('')); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function testInsertWhenStoreNotInstalledCausesTermStoreException() { |
| 36 | - $id = new ItemId( 'Q1337' ); |
|
| 36 | + $id = new ItemId('Q1337'); |
|
| 37 | 37 | |
| 38 | 38 | $fingerprint = new Fingerprint(); |
| 39 | - $fingerprint->setLabel( 'en', 'EN label' ); |
|
| 39 | + $fingerprint->setLabel('en', 'EN label'); |
|
| 40 | 40 | |
| 41 | - $this->expectException( TermStoreException::class ); |
|
| 42 | - $this->store->storeEntityFingerprint( $id, $fingerprint ); |
|
| 41 | + $this->expectException(TermStoreException::class); |
|
| 42 | + $this->store->storeEntityFingerprint($id, $fingerprint); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | } |