@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param Connection $connection |
22 | 22 | * @param string $tableName |
23 | 23 | */ |
24 | - public function __construct( Connection $connection, $tableName ) { |
|
24 | + public function __construct(Connection $connection, $tableName) { |
|
25 | 25 | $this->connection = $connection; |
26 | 26 | $this->tableName = $tableName; |
27 | 27 | } |
@@ -32,35 +32,35 @@ discard block |
||
32 | 32 | * @return string|null |
33 | 33 | * @throws PropertyTypeLookupException |
34 | 34 | */ |
35 | - public function getTypeOfProperty( PropertyId $id ) { |
|
36 | - $query = $this->buildQuery( $id ); |
|
35 | + public function getTypeOfProperty(PropertyId $id) { |
|
36 | + $query = $this->buildQuery($id); |
|
37 | 37 | |
38 | 38 | try { |
39 | 39 | $queryResult = $query->execute(); |
40 | 40 | } |
41 | - catch ( DBALException $ex ) { |
|
42 | - throw new PropertyTypeLookupException( $ex->getMessage(), $ex ); |
|
41 | + catch (DBALException $ex) { |
|
42 | + throw new PropertyTypeLookupException($ex->getMessage(), $ex); |
|
43 | 43 | } |
44 | 44 | |
45 | - return $this->getTypeFromResult( $queryResult ); |
|
45 | + return $this->getTypeFromResult($queryResult); |
|
46 | 46 | } |
47 | 47 | |
48 | - private function buildQuery( PropertyId $id ) { |
|
48 | + private function buildQuery(PropertyId $id) { |
|
49 | 49 | return $this->connection->createQueryBuilder() |
50 | - ->select( 'property_type' ) |
|
51 | - ->from( $this->tableName ) |
|
52 | - ->where( 'property_id = ?' ) |
|
53 | - ->setParameter( 0, (int)$id->getNumericId() ); |
|
50 | + ->select('property_type') |
|
51 | + ->from($this->tableName) |
|
52 | + ->where('property_id = ?') |
|
53 | + ->setParameter(0, (int)$id->getNumericId()); |
|
54 | 54 | } |
55 | 55 | |
56 | - private function getTypeFromResult( \Traversable $rows ) { |
|
57 | - $rows = iterator_to_array( $rows ); |
|
56 | + private function getTypeFromResult(\Traversable $rows) { |
|
57 | + $rows = iterator_to_array($rows); |
|
58 | 58 | |
59 | - if ( count( $rows ) < 1 ) { |
|
59 | + if (count($rows) < 1) { |
|
60 | 60 | return null; |
61 | 61 | } |
62 | 62 | |
63 | - return reset( $rows )['property_type']; |
|
63 | + return reset($rows)['property_type']; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -37,8 +37,7 @@ |
||
37 | 37 | |
38 | 38 | try { |
39 | 39 | $queryResult = $query->execute(); |
40 | - } |
|
41 | - catch ( DBALException $ex ) { |
|
40 | + } catch ( DBALException $ex ) { |
|
42 | 41 | throw new PropertyTypeLookupException( $ex->getMessage(), $ex ); |
43 | 42 | } |
44 | 43 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param ItemStore $itemStore |
23 | 23 | * @param PropertyStore $propertyStore |
24 | 24 | */ |
25 | - public function __construct( ItemStore $itemStore, PropertyStore $propertyStore ) { |
|
25 | + public function __construct(ItemStore $itemStore, PropertyStore $propertyStore) { |
|
26 | 26 | $this->itemStore = $itemStore; |
27 | 27 | $this->propertyStore = $propertyStore; |
28 | 28 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @throws EntityStoreException |
34 | 34 | */ |
35 | - public function storeItemRow( ItemRow $itemRow ) { |
|
36 | - $this->itemStore->storeItemRow( $itemRow ); |
|
35 | + public function storeItemRow(ItemRow $itemRow) { |
|
36 | + $this->itemStore->storeItemRow($itemRow); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @throws EntityStoreException |
43 | 43 | */ |
44 | - public function storePropertyRow( PropertyRow $propertyRow ) { |
|
45 | - $this->propertyStore->storePropertyRow( $propertyRow ); |
|
44 | + public function storePropertyRow(PropertyRow $propertyRow) { |
|
45 | + $this->propertyStore->storePropertyRow($propertyRow); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return ItemRow|null |
51 | 51 | * @throws EntityStoreException |
52 | 52 | */ |
53 | - public function getItemRowByNumericItemId( $numericItemId ) { |
|
54 | - return $this->itemStore->getItemRowByNumericItemId( $numericItemId ); |
|
53 | + public function getItemRowByNumericItemId($numericItemId) { |
|
54 | + return $this->itemStore->getItemRowByNumericItemId($numericItemId); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @return PropertyRow|null |
61 | 61 | * @throws EntityStoreException |
62 | 62 | */ |
63 | - public function getPropertyRowByNumericPropertyId( $numericPropertyId ) { |
|
64 | - return $this->propertyStore->getPropertyRowByNumericPropertyId( $numericPropertyId ); |
|
63 | + public function getPropertyRowByNumericPropertyId($numericPropertyId) { |
|
64 | + return $this->propertyStore->getPropertyRowByNumericPropertyId($numericPropertyId); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @return PropertyInfo[] |
72 | 72 | * @throws EntityStoreException |
73 | 73 | */ |
74 | - public function getPropertyInfo( $limit, $offset ) { |
|
75 | - return $this->propertyStore->getPropertyInfo( $limit, $offset ); |
|
74 | + public function getPropertyInfo($limit, $offset) { |
|
75 | + return $this->propertyStore->getPropertyInfo($limit, $offset); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return ItemInfo[] |
83 | 83 | * @throws EntityStoreException |
84 | 84 | */ |
85 | - public function getItemInfo( $limit, $offset ) { |
|
86 | - return $this->itemStore->getItemInfo( $limit, $offset ); |
|
85 | + public function getItemInfo($limit, $offset) { |
|
86 | + return $this->itemStore->getItemInfo($limit, $offset); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | private $itemSerializer; |
18 | 18 | private $typeExtractor; |
19 | 19 | |
20 | - public function __construct( Serializer $itemSerializer, ItemTypeExtractor $typeExtractor ) { |
|
20 | + public function __construct(Serializer $itemSerializer, ItemTypeExtractor $typeExtractor) { |
|
21 | 21 | $this->itemSerializer = $itemSerializer; |
22 | 22 | $this->typeExtractor = $typeExtractor; |
23 | 23 | } |
@@ -29,39 +29,39 @@ discard block |
||
29 | 29 | * @return ItemRow |
30 | 30 | * @throws InvalidArgumentException |
31 | 31 | */ |
32 | - public function newFromItemAndPageInfo( Item $item, EntityPageInfo $pageInfo ) { |
|
33 | - if ( $item->getId() === null ) { |
|
34 | - throw new InvalidArgumentException( 'The items id cannot be null' ); |
|
32 | + public function newFromItemAndPageInfo(Item $item, EntityPageInfo $pageInfo) { |
|
33 | + if ($item->getId() === null) { |
|
34 | + throw new InvalidArgumentException('The items id cannot be null'); |
|
35 | 35 | } |
36 | 36 | |
37 | - return ( new ItemRow() ) |
|
38 | - ->setPageTitle( $pageInfo->getPageTitle() ) |
|
39 | - ->setRevisionId( $pageInfo->getRevisionId() ) |
|
40 | - ->setRevisionTime( $pageInfo->getRevisionTime() ) |
|
41 | - ->setEnglishLabel( $this->getEnglishLabel( $item ) ) |
|
42 | - ->setItemType( $this->getItemType( $item ) ) |
|
43 | - ->setNumericItemId( $item->getId()->getNumericId() ) |
|
44 | - ->setItemJson( $this->getItemJson( $item ) ) |
|
45 | - ->setEnglishWikipediaTitle( $this->getEnWikiTitle( $item ) ); |
|
37 | + return (new ItemRow()) |
|
38 | + ->setPageTitle($pageInfo->getPageTitle()) |
|
39 | + ->setRevisionId($pageInfo->getRevisionId()) |
|
40 | + ->setRevisionTime($pageInfo->getRevisionTime()) |
|
41 | + ->setEnglishLabel($this->getEnglishLabel($item)) |
|
42 | + ->setItemType($this->getItemType($item)) |
|
43 | + ->setNumericItemId($item->getId()->getNumericId()) |
|
44 | + ->setItemJson($this->getItemJson($item)) |
|
45 | + ->setEnglishWikipediaTitle($this->getEnWikiTitle($item)); |
|
46 | 46 | } |
47 | 47 | |
48 | - private function getItemJson( Item $item ) { |
|
49 | - return json_encode( $this->itemSerializer->serialize( $item ) ); |
|
48 | + private function getItemJson(Item $item) { |
|
49 | + return json_encode($this->itemSerializer->serialize($item)); |
|
50 | 50 | } |
51 | 51 | |
52 | - private function getItemType( Item $item ) { |
|
53 | - return $this->typeExtractor->getTypeOfItem( $item ); |
|
52 | + private function getItemType(Item $item) { |
|
53 | + return $this->typeExtractor->getTypeOfItem($item); |
|
54 | 54 | } |
55 | 55 | |
56 | - private function getEnglishLabel( Item $item ) { |
|
57 | - return $item->getFingerprint()->hasLabel( 'en' ) ? |
|
58 | - $item->getFingerprint()->getLabel( 'en' )->getText() |
|
56 | + private function getEnglishLabel(Item $item) { |
|
57 | + return $item->getFingerprint()->hasLabel('en') ? |
|
58 | + $item->getFingerprint()->getLabel('en')->getText() |
|
59 | 59 | : null; |
60 | 60 | } |
61 | 61 | |
62 | - private function getEnWikiTitle( Item $item ) { |
|
63 | - return $item->getSiteLinkList()->hasLinkWithSiteId( 'enwiki' ) ? |
|
64 | - $item->getSiteLinkList()->getBySiteId( 'enwiki' )->getPageName() : null; |
|
62 | + private function getEnWikiTitle(Item $item) { |
|
63 | + return $item->getSiteLinkList()->hasLinkWithSiteId('enwiki') ? |
|
64 | + $item->getSiteLinkList()->getBySiteId('enwiki')->getPageName() : null; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param Connection $connection |
24 | 24 | * @param string $tableName |
25 | 25 | */ |
26 | - public function __construct( Connection $connection, $tableName ) { |
|
26 | + public function __construct(Connection $connection, $tableName) { |
|
27 | 27 | $this->connection = $connection; |
28 | 28 | $this->tableName = $tableName; |
29 | 29 | } |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws EntityStoreException |
35 | 35 | */ |
36 | - public function storeItemRow( ItemRow $itemRow ) { |
|
37 | - $this->deleteItemById( ItemId::newFromNumber( $itemRow->getNumericItemId() ) ); |
|
36 | + public function storeItemRow(ItemRow $itemRow) { |
|
37 | + $this->deleteItemById(ItemId::newFromNumber($itemRow->getNumericItemId())); |
|
38 | 38 | |
39 | 39 | try { |
40 | 40 | $this->connection->insert( |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | ] |
54 | 54 | ); |
55 | 55 | } |
56 | - catch ( DBALException $ex ) { |
|
57 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
56 | + catch (DBALException $ex) { |
|
57 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @throws EntityStoreException |
65 | 65 | */ |
66 | - public function deleteItemById( ItemId $itemId ) { |
|
66 | + public function deleteItemById(ItemId $itemId) { |
|
67 | 67 | try { |
68 | 68 | $this->connection->delete( |
69 | 69 | $this->tableName, |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | ] |
73 | 73 | ); |
74 | 74 | } |
75 | - catch ( DBALException $ex ) { |
|
76 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
75 | + catch (DBALException $ex) { |
|
76 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -82,18 +82,18 @@ discard block |
||
82 | 82 | * @return ItemRow|null |
83 | 83 | * @throws EntityStoreException |
84 | 84 | */ |
85 | - public function getItemRowByNumericItemId( $numericItemId ) { |
|
85 | + public function getItemRowByNumericItemId($numericItemId) { |
|
86 | 86 | try { |
87 | 87 | $rows = $this->selectItems() |
88 | - ->where( 'item_id = ?' ) |
|
89 | - ->setParameter( 0, (int)$numericItemId ) |
|
88 | + ->where('item_id = ?') |
|
89 | + ->setParameter(0, (int)$numericItemId) |
|
90 | 90 | ->execute(); |
91 | 91 | } |
92 | - catch ( DBALException $ex ) { |
|
93 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
92 | + catch (DBALException $ex) { |
|
93 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
94 | 94 | } |
95 | 95 | |
96 | - return $this->newItemRowFromResult( $rows ); |
|
96 | + return $this->newItemRowFromResult($rows); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | private function selectItems() { |
@@ -106,38 +106,38 @@ discard block |
||
106 | 106 | 'item_type', |
107 | 107 | 'item_label_en', |
108 | 108 | 'wp_title_en' |
109 | - )->from( $this->tableName ); |
|
109 | + )->from($this->tableName); |
|
110 | 110 | } |
111 | 111 | |
112 | - private function newItemRowFromResult( \Traversable $rows ) { |
|
113 | - $rows = iterator_to_array( $rows ); |
|
112 | + private function newItemRowFromResult(\Traversable $rows) { |
|
113 | + $rows = iterator_to_array($rows); |
|
114 | 114 | |
115 | - if ( count( $rows ) < 1 ) { |
|
115 | + if (count($rows) < 1) { |
|
116 | 116 | return null; |
117 | 117 | } |
118 | 118 | |
119 | - $row = reset( $rows ); |
|
119 | + $row = reset($rows); |
|
120 | 120 | |
121 | - return ( new ItemRow() ) |
|
122 | - ->setItemJson( $row['item_json'] ) |
|
123 | - ->setNumericItemId( $row['item_id'] ) |
|
124 | - ->setPageTitle( $row['page_title'] ) |
|
125 | - ->setRevisionId( $row['revision_id'] ) |
|
126 | - ->setRevisionTime( $row['revision_time'] ) |
|
127 | - ->setItemType( $row['item_type'] ) |
|
128 | - ->setEnglishWikipediaTitle( $row['wp_title_en'] ) |
|
129 | - ->setEnglishLabel( $row['item_label_en'] ); |
|
121 | + return (new ItemRow()) |
|
122 | + ->setItemJson($row['item_json']) |
|
123 | + ->setNumericItemId($row['item_id']) |
|
124 | + ->setPageTitle($row['page_title']) |
|
125 | + ->setRevisionId($row['revision_id']) |
|
126 | + ->setRevisionTime($row['revision_time']) |
|
127 | + ->setItemType($row['item_type']) |
|
128 | + ->setEnglishWikipediaTitle($row['wp_title_en']) |
|
129 | + ->setEnglishLabel($row['item_label_en']); |
|
130 | 130 | } |
131 | 131 | |
132 | - private function newItemInfoFromResultRow( array $row ) { |
|
133 | - return ( new ItemInfo() ) |
|
134 | - ->setNumericItemId( $row['item_id'] ) |
|
135 | - ->setPageTitle( $row['page_title'] ) |
|
136 | - ->setRevisionId( $row['revision_id'] ) |
|
137 | - ->setRevisionTime( $row['revision_time'] ) |
|
138 | - ->setItemType( $row['item_type'] ) |
|
139 | - ->setEnglishWikipediaTitle( $row['wp_title_en'] ) |
|
140 | - ->setEnglishLabel( $row['item_label_en'] ); |
|
132 | + private function newItemInfoFromResultRow(array $row) { |
|
133 | + return (new ItemInfo()) |
|
134 | + ->setNumericItemId($row['item_id']) |
|
135 | + ->setPageTitle($row['page_title']) |
|
136 | + ->setRevisionId($row['revision_id']) |
|
137 | + ->setRevisionTime($row['revision_time']) |
|
138 | + ->setItemType($row['item_type']) |
|
139 | + ->setEnglishWikipediaTitle($row['wp_title_en']) |
|
140 | + ->setEnglishLabel($row['item_label_en']); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | private function selectItemInfoSets() { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | 'item_type', |
150 | 150 | 'item_label_en', |
151 | 151 | 'wp_title_en' |
152 | - )->from( $this->tableName ); |
|
152 | + )->from($this->tableName); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,31 +160,31 @@ discard block |
||
160 | 160 | * @return ItemInfo[] |
161 | 161 | * @throws EntityStoreException |
162 | 162 | */ |
163 | - public function getItemInfo( $limit, $offset, $itemType = null ) { |
|
163 | + public function getItemInfo($limit, $offset, $itemType = null) { |
|
164 | 164 | $query = $this->selectItemInfoSets() |
165 | - ->orderBy( 'item_id', 'asc' ) |
|
166 | - ->setMaxResults( $limit ) |
|
167 | - ->setFirstResult( $offset ); |
|
165 | + ->orderBy('item_id', 'asc') |
|
166 | + ->setMaxResults($limit) |
|
167 | + ->setFirstResult($offset); |
|
168 | 168 | |
169 | - if ( is_int( $itemType ) ) { |
|
170 | - $query->where( 'item_type = ?' )->setParameter( 0, $itemType ); |
|
169 | + if (is_int($itemType)) { |
|
170 | + $query->where('item_type = ?')->setParameter(0, $itemType); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | try { |
174 | 174 | $rows = $query->execute(); |
175 | 175 | } |
176 | - catch ( DBALException $ex ) { |
|
177 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
176 | + catch (DBALException $ex) { |
|
177 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
178 | 178 | } |
179 | 179 | |
180 | - return $this->newItemInfoArrayFromResult( $rows ); |
|
180 | + return $this->newItemInfoArrayFromResult($rows); |
|
181 | 181 | } |
182 | 182 | |
183 | - private function newItemInfoArrayFromResult( \Traversable $rows ) { |
|
183 | + private function newItemInfoArrayFromResult(\Traversable $rows) { |
|
184 | 184 | $infoList = []; |
185 | 185 | |
186 | - foreach ( $rows as $resultRow ) { |
|
187 | - $infoList[] = $this->newItemInfoFromResultRow( $resultRow ); |
|
186 | + foreach ($rows as $resultRow) { |
|
187 | + $infoList[] = $this->newItemInfoFromResultRow($resultRow); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | return $infoList; |
@@ -197,28 +197,28 @@ discard block |
||
197 | 197 | * @return int[] |
198 | 198 | * @throws EntityStoreException |
199 | 199 | */ |
200 | - public function getItemTypes( $limit = 100, $offset = 0 ) { |
|
200 | + public function getItemTypes($limit = 100, $offset = 0) { |
|
201 | 201 | try { |
202 | 202 | $rows = $this->connection->createQueryBuilder() |
203 | - ->select( 'DISTINCT item_type' ) |
|
204 | - ->from( $this->tableName ) |
|
205 | - ->where( 'item_type IS NOT NULL' ) |
|
206 | - ->orderBy( 'item_type', 'ASC' ) |
|
207 | - ->setMaxResults( $limit ) |
|
208 | - ->setFirstResult( $offset ) |
|
203 | + ->select('DISTINCT item_type') |
|
204 | + ->from($this->tableName) |
|
205 | + ->where('item_type IS NOT NULL') |
|
206 | + ->orderBy('item_type', 'ASC') |
|
207 | + ->setMaxResults($limit) |
|
208 | + ->setFirstResult($offset) |
|
209 | 209 | ->execute(); |
210 | 210 | } |
211 | - catch ( DBALException $ex ) { |
|
212 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
211 | + catch (DBALException $ex) { |
|
212 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
213 | 213 | } |
214 | 214 | |
215 | - return $this->getTypeArrayFromRows( $rows ); |
|
215 | + return $this->getTypeArrayFromRows($rows); |
|
216 | 216 | } |
217 | 217 | |
218 | - private function getTypeArrayFromRows( \Traversable $rows ) { |
|
218 | + private function getTypeArrayFromRows(\Traversable $rows) { |
|
219 | 219 | $types = []; |
220 | 220 | |
221 | - foreach ( $rows as $row ) { |
|
221 | + foreach ($rows as $row) { |
|
222 | 222 | $types[] = (int)$row['item_type']; |
223 | 223 | } |
224 | 224 | |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * @return ItemId|null |
232 | 232 | * @throws EntityStoreException |
233 | 233 | */ |
234 | - public function getIdForEnWikiPage( $pageName ) { |
|
234 | + public function getIdForEnWikiPage($pageName) { |
|
235 | 235 | try { |
236 | 236 | $rows = $this->connection->createQueryBuilder() |
237 | - ->select( 'item_id' ) |
|
238 | - ->from( $this->tableName ) |
|
239 | - ->where( 'wp_title_en = ?' ) |
|
240 | - ->setParameter( 0, $pageName ) |
|
241 | - ->setMaxResults( 1 ) |
|
237 | + ->select('item_id') |
|
238 | + ->from($this->tableName) |
|
239 | + ->where('wp_title_en = ?') |
|
240 | + ->setParameter(0, $pageName) |
|
241 | + ->setMaxResults(1) |
|
242 | 242 | ->execute(); |
243 | 243 | } |
244 | - catch ( DBALException $ex ) { |
|
245 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
244 | + catch (DBALException $ex) { |
|
245 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
246 | 246 | } |
247 | 247 | |
248 | - foreach ( $rows as $row ) { |
|
249 | - return ItemId::newFromNumber( $row['item_id'] ); |
|
248 | + foreach ($rows as $row) { |
|
249 | + return ItemId::newFromNumber($row['item_id']); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return null; |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | 'item_json' => $itemRow->getItemJson(), |
53 | 53 | ] |
54 | 54 | ); |
55 | - } |
|
56 | - catch ( DBALException $ex ) { |
|
55 | + } catch ( DBALException $ex ) { |
|
57 | 56 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
58 | 57 | } |
59 | 58 | } |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | 'item_id' => $itemId->getNumericId() |
72 | 71 | ] |
73 | 72 | ); |
74 | - } |
|
75 | - catch ( DBALException $ex ) { |
|
73 | + } catch ( DBALException $ex ) { |
|
76 | 74 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
77 | 75 | } |
78 | 76 | } |
@@ -88,8 +86,7 @@ discard block |
||
88 | 86 | ->where( 'item_id = ?' ) |
89 | 87 | ->setParameter( 0, (int)$numericItemId ) |
90 | 88 | ->execute(); |
91 | - } |
|
92 | - catch ( DBALException $ex ) { |
|
89 | + } catch ( DBALException $ex ) { |
|
93 | 90 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
94 | 91 | } |
95 | 92 | |
@@ -172,8 +169,7 @@ discard block |
||
172 | 169 | |
173 | 170 | try { |
174 | 171 | $rows = $query->execute(); |
175 | - } |
|
176 | - catch ( DBALException $ex ) { |
|
172 | + } catch ( DBALException $ex ) { |
|
177 | 173 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
178 | 174 | } |
179 | 175 | |
@@ -207,8 +203,7 @@ discard block |
||
207 | 203 | ->setMaxResults( $limit ) |
208 | 204 | ->setFirstResult( $offset ) |
209 | 205 | ->execute(); |
210 | - } |
|
211 | - catch ( DBALException $ex ) { |
|
206 | + } catch ( DBALException $ex ) { |
|
212 | 207 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
213 | 208 | } |
214 | 209 | |
@@ -240,8 +235,7 @@ discard block |
||
240 | 235 | ->setParameter( 0, $pageName ) |
241 | 236 | ->setMaxResults( 1 ) |
242 | 237 | ->execute(); |
243 | - } |
|
244 | - catch ( DBALException $ex ) { |
|
238 | + } catch ( DBALException $ex ) { |
|
245 | 239 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
246 | 240 | } |
247 | 241 |
@@ -17,6 +17,6 @@ |
||
17 | 17 | * |
18 | 18 | * @return int|null |
19 | 19 | */ |
20 | - public function getTypeOfItem( Item $item ); |
|
20 | + public function getTypeOfItem(Item $item); |
|
21 | 21 | |
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | private $schemaManager; |
17 | 17 | private $config; |
18 | 18 | |
19 | - public function __construct( AbstractSchemaManager $schemaManager, EntityStoreConfig $config ) { |
|
19 | + public function __construct(AbstractSchemaManager $schemaManager, EntityStoreConfig $config) { |
|
20 | 20 | $this->schemaManager = $schemaManager; |
21 | 21 | $this->config = $config; |
22 | 22 | } |
@@ -25,54 +25,54 @@ discard block |
||
25 | 25 | * @throws DBALException |
26 | 26 | */ |
27 | 27 | public function install() { |
28 | - $this->schemaManager->createTable( $this->newItemTable() ); |
|
29 | - $this->schemaManager->createTable( $this->newPropertyTable() ); |
|
28 | + $this->schemaManager->createTable($this->newItemTable()); |
|
29 | + $this->schemaManager->createTable($this->newPropertyTable()); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | private function newItemTable() { |
33 | - $table = new Table( $this->config->getItemTableName() ); |
|
34 | - |
|
35 | - $table->addColumn( 'item_id', Type::BIGINT ); |
|
36 | - $table->addColumn( 'item_type', Type::BIGINT, [ 'notnull' => false ] ); |
|
37 | - $table->addColumn( 'page_title', Type::STRING, [ 'length' => 255 ] ); |
|
38 | - $table->addColumn( 'revision_id', Type::BIGINT ); |
|
39 | - $table->addColumn( 'revision_time', Type::STRING, [ 'length' => 25 ] ); |
|
40 | - $table->addColumn( 'item_json', Type::BLOB ); |
|
41 | - $table->addColumn( 'item_label_en', Type::STRING, [ 'length' => 255, 'notnull' => false ] ); |
|
42 | - $table->addColumn( 'wp_title_en', Type::STRING, [ 'length' => 255, 'notnull' => false ] ); |
|
43 | - |
|
44 | - $table->addIndex( [ 'item_id' ] ); |
|
45 | - $table->addIndex( [ 'item_type' ] ); |
|
46 | - $table->addIndex( [ 'page_title' ] ); |
|
47 | - $table->addIndex( [ 'revision_id' ] ); |
|
48 | - $table->addIndex( [ 'revision_time' ] ); |
|
49 | - $table->addIndex( [ 'wp_title_en' ] ); |
|
33 | + $table = new Table($this->config->getItemTableName()); |
|
34 | + |
|
35 | + $table->addColumn('item_id', Type::BIGINT); |
|
36 | + $table->addColumn('item_type', Type::BIGINT, ['notnull' => false]); |
|
37 | + $table->addColumn('page_title', Type::STRING, ['length' => 255]); |
|
38 | + $table->addColumn('revision_id', Type::BIGINT); |
|
39 | + $table->addColumn('revision_time', Type::STRING, ['length' => 25]); |
|
40 | + $table->addColumn('item_json', Type::BLOB); |
|
41 | + $table->addColumn('item_label_en', Type::STRING, ['length' => 255, 'notnull' => false]); |
|
42 | + $table->addColumn('wp_title_en', Type::STRING, ['length' => 255, 'notnull' => false]); |
|
43 | + |
|
44 | + $table->addIndex(['item_id']); |
|
45 | + $table->addIndex(['item_type']); |
|
46 | + $table->addIndex(['page_title']); |
|
47 | + $table->addIndex(['revision_id']); |
|
48 | + $table->addIndex(['revision_time']); |
|
49 | + $table->addIndex(['wp_title_en']); |
|
50 | 50 | |
51 | 51 | return $table; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function newPropertyTable() { |
55 | - $table = new Table( $this->config->getPropertyTableName() ); |
|
55 | + $table = new Table($this->config->getPropertyTableName()); |
|
56 | 56 | |
57 | - $table->addColumn( 'property_id', Type::BIGINT ); |
|
58 | - $table->addColumn( 'property_json', Type::BLOB ); |
|
59 | - $table->addColumn( 'page_title', Type::STRING, [ 'length' => 255 ] ); |
|
60 | - $table->addColumn( 'revision_id', Type::BIGINT ); |
|
61 | - $table->addColumn( 'revision_time', Type::STRING, [ 'length' => 25 ] ); |
|
62 | - $table->addColumn( 'property_type', Type::STRING, [ 'length' => 30 ] ); |
|
57 | + $table->addColumn('property_id', Type::BIGINT); |
|
58 | + $table->addColumn('property_json', Type::BLOB); |
|
59 | + $table->addColumn('page_title', Type::STRING, ['length' => 255]); |
|
60 | + $table->addColumn('revision_id', Type::BIGINT); |
|
61 | + $table->addColumn('revision_time', Type::STRING, ['length' => 25]); |
|
62 | + $table->addColumn('property_type', Type::STRING, ['length' => 30]); |
|
63 | 63 | |
64 | - $table->addIndex( [ 'property_id' ] ); |
|
65 | - $table->addIndex( [ 'page_title' ] ); |
|
66 | - $table->addIndex( [ 'revision_id' ] ); |
|
67 | - $table->addIndex( [ 'revision_time' ] ); |
|
68 | - $table->addIndex( [ 'property_type' ] ); |
|
64 | + $table->addIndex(['property_id']); |
|
65 | + $table->addIndex(['page_title']); |
|
66 | + $table->addIndex(['revision_id']); |
|
67 | + $table->addIndex(['revision_time']); |
|
68 | + $table->addIndex(['property_type']); |
|
69 | 69 | |
70 | 70 | return $table; |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function uninstall() { |
74 | - $this->schemaManager->dropTable( $this->config->getItemTableName() ); |
|
75 | - $this->schemaManager->dropTable( $this->config->getPropertyTableName() ); |
|
74 | + $this->schemaManager->dropTable($this->config->getItemTableName()); |
|
75 | + $this->schemaManager->dropTable($this->config->getPropertyTableName()); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
79 | 79 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string|null $enLabel |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function setEnglishLabel( $enLabel ) { |
|
26 | + public function setEnglishLabel($enLabel) { |
|
27 | 27 | $this->enLabel = $enLabel; |
28 | 28 | return $this; |
29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param int|string $itemId |
33 | 33 | * @return $this |
34 | 34 | */ |
35 | - public function setNumericItemId( $itemId ) { |
|
35 | + public function setNumericItemId($itemId) { |
|
36 | 36 | $this->itemId = (int)$itemId; |
37 | 37 | return $this; |
38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param int|null $itemType |
42 | 42 | * @return $this |
43 | 43 | */ |
44 | - public function setItemType( $itemType ) { |
|
44 | + public function setItemType($itemType) { |
|
45 | 45 | $this->itemType = $itemType === null ? null : (int)$itemType; |
46 | 46 | return $this; |
47 | 47 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $pageTitle |
51 | 51 | * @return $this |
52 | 52 | */ |
53 | - public function setPageTitle( $pageTitle ) { |
|
53 | + public function setPageTitle($pageTitle) { |
|
54 | 54 | $this->pageTitle = $pageTitle; |
55 | 55 | return $this; |
56 | 56 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param int|string $revisionId |
60 | 60 | * @return $this |
61 | 61 | */ |
62 | - public function setRevisionId( $revisionId ) { |
|
62 | + public function setRevisionId($revisionId) { |
|
63 | 63 | $this->revisionId = (int)$revisionId; |
64 | 64 | return $this; |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $revisionTime |
69 | 69 | * @return $this |
70 | 70 | */ |
71 | - public function setRevisionTime( $revisionTime ) { |
|
71 | + public function setRevisionTime($revisionTime) { |
|
72 | 72 | $this->revisionTime = $revisionTime; |
73 | 73 | return $this; |
74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param string|null $enWikiTitle |
78 | 78 | * @return $this |
79 | 79 | */ |
80 | - public function setEnglishWikipediaTitle( $enWikiTitle ) { |
|
80 | + public function setEnglishWikipediaTitle($enWikiTitle) { |
|
81 | 81 | $this->enWikiTitle = $enWikiTitle; |
82 | 82 | return $this; |
83 | 83 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * @param string $propertyJson |
18 | 18 | * @param PropertyInfo $info |
19 | 19 | */ |
20 | - public function __construct( $propertyJson, PropertyInfo $info ) { |
|
20 | + public function __construct($propertyJson, PropertyInfo $info) { |
|
21 | 21 | $this->propertyJson = $propertyJson; |
22 | 22 | $this->propertyInfo = $info; |
23 | 23 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @param string $revisionTime |
24 | 24 | * @param string $propertyType |
25 | 25 | */ |
26 | - public function __construct( $numericPropertyId, $pageTitle, $revisionId, $revisionTime, $propertyType ) { |
|
26 | + public function __construct($numericPropertyId, $pageTitle, $revisionId, $revisionTime, $propertyType) { |
|
27 | 27 | $this->propertyId = (int)$numericPropertyId; |
28 | 28 | $this->pageTitle = $pageTitle; |
29 | 29 | $this->revisionId = (int)$revisionId; |