@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string $pageTitle |
40 | 40 | * @return $this |
41 | 41 | */ |
42 | - public function setPageTitle( $pageTitle ) { |
|
42 | + public function setPageTitle($pageTitle) { |
|
43 | 43 | $this->pageTitle = $pageTitle; |
44 | 44 | return $this; |
45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param int|string $revisionId |
49 | 49 | * @return $this |
50 | 50 | */ |
51 | - public function setRevisionId( $revisionId ) { |
|
51 | + public function setRevisionId($revisionId) { |
|
52 | 52 | $this->revisionId = (int)$revisionId; |
53 | 53 | return $this; |
54 | 54 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $revisionTime |
58 | 58 | * @return $this |
59 | 59 | */ |
60 | - public function setRevisionTime( $revisionTime ) { |
|
60 | + public function setRevisionTime($revisionTime) { |
|
61 | 61 | $this->revisionTime = $revisionTime; |
62 | 62 | return $this; |
63 | 63 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | private $connection; |
14 | 14 | private $config; |
15 | 15 | |
16 | - public function __construct( Connection $connection, EntityStoreConfig $config ) { |
|
16 | + public function __construct(Connection $connection, EntityStoreConfig $config) { |
|
17 | 17 | $this->connection = $connection; |
18 | 18 | $this->config = $config; |
19 | 19 | } |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | public function newItemStore() { |
29 | - return new ItemStore( $this->connection, $this->config->getItemTableName() ); |
|
29 | + return new ItemStore($this->connection, $this->config->getItemTableName()); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function newPropertyStore() { |
33 | - return new PropertyStore( $this->connection, $this->config->getPropertyTableName() ); |
|
33 | + return new PropertyStore($this->connection, $this->config->getPropertyTableName()); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function newPropertyTypeLookup() { |
37 | - return new PropertyTypeLookup( $this->connection, $this->config->getPropertyTableName() ); |
|
37 | + return new PropertyTypeLookup($this->connection, $this->config->getPropertyTableName()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | private $instanceOfPropertyId; |
22 | 22 | |
23 | 23 | public function __construct() { |
24 | - $this->instanceOfPropertyId = new PropertyId( 'P31' ); |
|
24 | + $this->instanceOfPropertyId = new PropertyId('P31'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return int|null |
33 | 33 | */ |
34 | - public function getTypeOfItem( Item $item ) { |
|
34 | + public function getTypeOfItem(Item $item) { |
|
35 | 35 | /** |
36 | 36 | * @var Statement $statement |
37 | 37 | */ |
38 | - foreach ( $item->getStatements() as $statement ) { |
|
39 | - if ( $statement->getPropertyId()->equals( $this->instanceOfPropertyId ) ) { |
|
38 | + foreach ($item->getStatements() as $statement) { |
|
39 | + if ($statement->getPropertyId()->equals($this->instanceOfPropertyId)) { |
|
40 | 40 | $valueSnak = $statement->getMainSnak(); |
41 | 41 | |
42 | - if ( $valueSnak instanceof PropertyValueSnak ) { |
|
42 | + if ($valueSnak instanceof PropertyValueSnak) { |
|
43 | 43 | $value = $valueSnak->getDataValue(); |
44 | 44 | |
45 | 45 | |
46 | - if ( $value instanceof EntityIdValue ) { |
|
46 | + if ($value instanceof EntityIdValue) { |
|
47 | 47 | |
48 | 48 | $itemId = $value->getEntityId(); |
49 | 49 | |
50 | - if ( $itemId instanceof ItemId ) { |
|
50 | + if ($itemId instanceof ItemId) { |
|
51 | 51 | return $itemId->getNumericId(); |
52 | 52 | } |
53 | 53 | } |
@@ -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 storePropertyRow( PropertyRow $propertyRow ) { |
|
37 | - $this->deletePropertyById( PropertyId::newFromNumber( $propertyRow->getNumericPropertyId() ) ); |
|
36 | + public function storePropertyRow(PropertyRow $propertyRow) { |
|
37 | + $this->deletePropertyById(PropertyId::newFromNumber($propertyRow->getNumericPropertyId())); |
|
38 | 38 | |
39 | 39 | try { |
40 | 40 | $this->connection->insert( |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | } |
54 | - catch ( DBALException $ex ) { |
|
55 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
54 | + catch (DBALException $ex) { |
|
55 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @throws EntityStoreException |
63 | 63 | */ |
64 | - public function deletePropertyById( PropertyId $propertyId ) { |
|
64 | + public function deletePropertyById(PropertyId $propertyId) { |
|
65 | 65 | try { |
66 | 66 | $this->connection->delete( |
67 | 67 | $this->tableName, |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | ] |
71 | 71 | ); |
72 | 72 | } |
73 | - catch ( DBALException $ex ) { |
|
74 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
73 | + catch (DBALException $ex) { |
|
74 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | * @return PropertyRow|null |
82 | 82 | * @throws EntityStoreException |
83 | 83 | */ |
84 | - public function getPropertyRowByNumericPropertyId( $numericPropertyId ) { |
|
84 | + public function getPropertyRowByNumericPropertyId($numericPropertyId) { |
|
85 | 85 | try { |
86 | 86 | $rows = $this->selectProperties() |
87 | - ->where( 'property_id = ?' ) |
|
88 | - ->setParameter( 0, (int)$numericPropertyId ) |
|
87 | + ->where('property_id = ?') |
|
88 | + ->setParameter(0, (int)$numericPropertyId) |
|
89 | 89 | ->execute(); |
90 | 90 | } |
91 | - catch ( DBALException $ex ) { |
|
92 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
91 | + catch (DBALException $ex) { |
|
92 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
93 | 93 | } |
94 | 94 | |
95 | - return $this->newPropertyRowFromResult( $rows ); |
|
95 | + return $this->newPropertyRowFromResult($rows); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | private function selectProperties() { |
@@ -103,25 +103,25 @@ discard block |
||
103 | 103 | 'revision_id', |
104 | 104 | 'revision_time', |
105 | 105 | 'property_type' |
106 | - )->from( $this->tableName ); |
|
106 | + )->from($this->tableName); |
|
107 | 107 | } |
108 | 108 | |
109 | - private function newPropertyRowFromResult( \Traversable $rows ) { |
|
110 | - $rows = iterator_to_array( $rows ); |
|
109 | + private function newPropertyRowFromResult(\Traversable $rows) { |
|
110 | + $rows = iterator_to_array($rows); |
|
111 | 111 | |
112 | - if ( count( $rows ) < 1 ) { |
|
112 | + if (count($rows) < 1) { |
|
113 | 113 | return null; |
114 | 114 | } |
115 | 115 | |
116 | - $row = reset( $rows ); |
|
116 | + $row = reset($rows); |
|
117 | 117 | |
118 | 118 | return new PropertyRow( |
119 | 119 | $row['property_json'], |
120 | - $this->newPropertyInfoFromResultRow( $row ) |
|
120 | + $this->newPropertyInfoFromResultRow($row) |
|
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
124 | - private function newPropertyInfoFromResultRow( array $row ) { |
|
124 | + private function newPropertyInfoFromResultRow(array $row) { |
|
125 | 125 | return new PropertyInfo( |
126 | 126 | $row['property_id'], |
127 | 127 | $row['page_title'], |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'revision_id', |
139 | 139 | 'revision_time', |
140 | 140 | 'property_type' |
141 | - )->from( $this->tableName ); |
|
141 | + )->from($this->tableName); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * @return PropertyInfo[] |
149 | 149 | * @throws EntityStoreException |
150 | 150 | */ |
151 | - public function getPropertyInfo( $limit, $offset ) { |
|
151 | + public function getPropertyInfo($limit, $offset) { |
|
152 | 152 | try { |
153 | 153 | $rows = $this->selectPropertyInfoSets() |
154 | - ->orderBy( 'property_id', 'asc' ) |
|
155 | - ->setMaxResults( $limit ) |
|
156 | - ->setFirstResult( $offset ) |
|
154 | + ->orderBy('property_id', 'asc') |
|
155 | + ->setMaxResults($limit) |
|
156 | + ->setFirstResult($offset) |
|
157 | 157 | ->execute(); |
158 | 158 | } |
159 | - catch ( DBALException $ex ) { |
|
160 | - throw new EntityStoreException( $ex->getMessage(), $ex ); |
|
159 | + catch (DBALException $ex) { |
|
160 | + throw new EntityStoreException($ex->getMessage(), $ex); |
|
161 | 161 | } |
162 | 162 | |
163 | - return $this->newPropertyInfoArrayFromResult( $rows ); |
|
163 | + return $this->newPropertyInfoArrayFromResult($rows); |
|
164 | 164 | } |
165 | 165 | |
166 | - private function newPropertyInfoArrayFromResult( \Traversable $rows ) { |
|
166 | + private function newPropertyInfoArrayFromResult(\Traversable $rows) { |
|
167 | 167 | $infoList = []; |
168 | 168 | |
169 | - foreach ( $rows as $resultRow ) { |
|
170 | - $infoList[] = $this->newPropertyInfoFromResultRow( $resultRow ); |
|
169 | + foreach ($rows as $resultRow) { |
|
170 | + $infoList[] = $this->newPropertyInfoFromResultRow($resultRow); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return $infoList; |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | 'property_type' => $propertyRow->getPropertyType(), |
51 | 51 | ) |
52 | 52 | ); |
53 | - } |
|
54 | - catch ( DBALException $ex ) { |
|
53 | + } catch ( DBALException $ex ) { |
|
55 | 54 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
56 | 55 | } |
57 | 56 | } |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | 'property_id' => $propertyId->getNumericId() |
70 | 69 | ] |
71 | 70 | ); |
72 | - } |
|
73 | - catch ( DBALException $ex ) { |
|
71 | + } catch ( DBALException $ex ) { |
|
74 | 72 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
75 | 73 | } |
76 | 74 | } |
@@ -87,8 +85,7 @@ discard block |
||
87 | 85 | ->where( 'property_id = ?' ) |
88 | 86 | ->setParameter( 0, (int)$numericPropertyId ) |
89 | 87 | ->execute(); |
90 | - } |
|
91 | - catch ( DBALException $ex ) { |
|
88 | + } catch ( DBALException $ex ) { |
|
92 | 89 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
93 | 90 | } |
94 | 91 | |
@@ -155,8 +152,7 @@ discard block |
||
155 | 152 | ->setMaxResults( $limit ) |
156 | 153 | ->setFirstResult( $offset ) |
157 | 154 | ->execute(); |
158 | - } |
|
159 | - catch ( DBALException $ex ) { |
|
155 | + } catch ( DBALException $ex ) { |
|
160 | 156 | throw new EntityStoreException( $ex->getMessage(), $ex ); |
161 | 157 | } |
162 | 158 |
@@ -8,8 +8,8 @@ |
||
8 | 8 | */ |
9 | 9 | class EntityStoreException extends \RuntimeException { |
10 | 10 | |
11 | - public function __construct( $message, \Exception $previous = null ) { |
|
12 | - parent::__construct( $message, 0, $previous ); |
|
11 | + public function __construct($message, \Exception $previous = null) { |
|
12 | + parent::__construct($message, 0, $previous); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -8,8 +8,8 @@ |
||
8 | 8 | */ |
9 | 9 | class PropertyTypeLookupException extends \RuntimeException { |
10 | 10 | |
11 | - public function __construct( $message, \Exception $previous = null ) { |
|
12 | - parent::__construct( $message, 0, $previous ); |
|
11 | + public function __construct($message, \Exception $previous = null) { |
|
12 | + parent::__construct($message, 0, $previous); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -10,16 +10,16 @@ |
||
10 | 10 | |
11 | 11 | private $prefix; |
12 | 12 | |
13 | - public function __construct( $tablePrefix = '' ) { |
|
13 | + public function __construct($tablePrefix = '') { |
|
14 | 14 | $this->prefix = $tablePrefix; |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function getItemTableName() { |
18 | - return $this->prefix . 'items'; |
|
18 | + return $this->prefix.'items'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function getPropertyTableName() { |
22 | - return $this->prefix . 'properties'; |
|
22 | + return $this->prefix.'properties'; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public function setUp() { |
29 | 29 | $factory = $this->createFactory(); |
30 | 30 | |
31 | - $this->insertPropertyRows( $factory->newPropertyStore() ); |
|
31 | + $this->insertPropertyRows($factory->newPropertyStore()); |
|
32 | 32 | |
33 | 33 | $this->lookup = $factory->newPropertyTypeLookup(); |
34 | 34 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | $connection = TestFixtureFactory::newInstance()->newConnection(); |
38 | 38 | $config = new EntityStoreConfig(); |
39 | 39 | |
40 | - $installer = new EntityStoreInstaller( $connection->getSchemaManager(), $config ); |
|
40 | + $installer = new EntityStoreInstaller($connection->getSchemaManager(), $config); |
|
41 | 41 | $installer->install(); |
42 | 42 | |
43 | - return new EntityStoreFactory( $connection, $config ); |
|
43 | + return new EntityStoreFactory($connection, $config); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | - private function insertPropertyRows( PropertyStore $store ) { |
|
47 | + private function insertPropertyRows(PropertyStore $store) { |
|
48 | 48 | $store->storePropertyRow( |
49 | 49 | new PropertyRow( |
50 | 50 | 'first property', |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | public function testGivenNotKnownProperty_nullIsReturned() { |
76 | - $this->assertNull( $this->lookup->getTypeOfProperty( new PropertyId( 'P42' ) ) ); |
|
76 | + $this->assertNull($this->lookup->getTypeOfProperty(new PropertyId('P42'))); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function testReturnsTypeOfP1() { |
80 | - $this->assertEquals( 'kittens', $this->lookup->getTypeOfProperty( new PropertyId( 'P1' ) ) ); |
|
80 | + $this->assertEquals('kittens', $this->lookup->getTypeOfProperty(new PropertyId('P1'))); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function testReturnsTypeOfP2() { |
84 | - $this->assertEquals( 'cats', $this->lookup->getTypeOfProperty( new PropertyId( 'P2' ) ) ); |
|
84 | + $this->assertEquals('cats', $this->lookup->getTypeOfProperty(new PropertyId('P2'))); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
@@ -31,20 +31,20 @@ |
||
31 | 31 | |
32 | 32 | $this->storeInstaller = new EntityStoreInstaller( |
33 | 33 | $this->schemaManager, |
34 | - new EntityStoreConfig( 'kittens_' ) |
|
34 | + new EntityStoreConfig('kittens_') |
|
35 | 35 | ); |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function testInstallationAndRemoval() { |
39 | 39 | $this->storeInstaller->install(); |
40 | 40 | |
41 | - $this->assertTrue( $this->schemaManager->tablesExist( 'kittens_items' ) ); |
|
42 | - $this->assertTrue( $this->schemaManager->tablesExist( 'kittens_properties' ) ); |
|
41 | + $this->assertTrue($this->schemaManager->tablesExist('kittens_items')); |
|
42 | + $this->assertTrue($this->schemaManager->tablesExist('kittens_properties')); |
|
43 | 43 | |
44 | 44 | $this->storeInstaller->uninstall(); |
45 | 45 | |
46 | - $this->assertFalse( $this->schemaManager->tablesExist( 'kittens_items' ) ); |
|
47 | - $this->assertFalse( $this->schemaManager->tablesExist( 'kittens_properties' ) ); |
|
46 | + $this->assertFalse($this->schemaManager->tablesExist('kittens_items')); |
|
47 | + $this->assertFalse($this->schemaManager->tablesExist('kittens_properties')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function testStoresPage() { |