| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 76 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 184 | public static function create() |
||
| 185 | { |
||
| 186 | $metadata = new SimpleMetadataProvider('WordPressEntities', 'WordPress'); |
||
| 187 | |||
| 188 | //Register the entity (resource) type 'Post' |
||
| 189 | $postsEntityType = $metadata->addEntityType(new ReflectionClass('Post'), 'Post', 'WordPress'); |
||
| 190 | $metadata->addKeyProperty($postsEntityType, 'PostID', EdmPrimitiveType::INT32); |
||
| 191 | $metadata->addPrimitiveProperty($postsEntityType, 'Author', EdmPrimitiveType::INT32); |
||
| 192 | $metadata->addPrimitiveProperty($postsEntityType, 'Date', EdmPrimitiveType::DATETIME); |
||
| 193 | $metadata->addPrimitiveProperty($postsEntityType, 'DateGmt', EdmPrimitiveType::DATETIME); |
||
| 194 | $metadata->addPrimitiveProperty($postsEntityType, 'Content', EdmPrimitiveType::STRING); |
||
| 195 | $metadata->addPrimitiveProperty($postsEntityType, 'Title', EdmPrimitiveType::STRING); |
||
| 196 | $metadata->addPrimitiveProperty($postsEntityType, 'Excerpt', EdmPrimitiveType::STRING); |
||
| 197 | $metadata->addPrimitiveProperty($postsEntityType, 'Status', EdmPrimitiveType::STRING); |
||
| 198 | $metadata->addPrimitiveProperty($postsEntityType, 'CommentStatus', EdmPrimitiveType::STRING); |
||
| 199 | $metadata->addPrimitiveProperty($postsEntityType, 'PingStatus', EdmPrimitiveType::STRING); |
||
| 200 | $metadata->addPrimitiveProperty($postsEntityType, 'Password', EdmPrimitiveType::STRING); |
||
| 201 | $metadata->addPrimitiveProperty($postsEntityType, 'Name', EdmPrimitiveType::STRING); |
||
| 202 | $metadata->addPrimitiveProperty($postsEntityType, 'ToPing', EdmPrimitiveType::STRING); |
||
| 203 | $metadata->addPrimitiveProperty($postsEntityType, 'Pinged', EdmPrimitiveType::STRING); |
||
| 204 | $metadata->addETagProperty($postsEntityType, 'Modified', EdmPrimitiveType::DATETIME); |
||
| 205 | $metadata->addPrimitiveProperty($postsEntityType, 'ModifiedGmt', EdmPrimitiveType::DATETIME); |
||
| 206 | $metadata->addPrimitiveProperty($postsEntityType, 'ContentFiltered', EdmPrimitiveType::STRING); |
||
| 207 | $metadata->addPrimitiveProperty($postsEntityType, 'ParentID', EdmPrimitiveType::INT32); |
||
| 208 | $metadata->addPrimitiveProperty($postsEntityType, 'Guid', EdmPrimitiveType::STRING); |
||
| 209 | $metadata->addPrimitiveProperty($postsEntityType, 'MenuOrder', EdmPrimitiveType::INT32); |
||
| 210 | $metadata->addPrimitiveProperty($postsEntityType, 'Type', EdmPrimitiveType::STRING); |
||
| 211 | $metadata->addPrimitiveProperty($postsEntityType, 'MimeType', EdmPrimitiveType::STRING); |
||
| 212 | $metadata->addPrimitiveProperty($postsEntityType, 'CommentCount', EdmPrimitiveType::INT32); |
||
| 213 | |||
| 214 | //Register the entity (resource) type 'Tag' |
||
| 215 | $tagsEntityType = $metadata->addEntityType(new ReflectionClass('Tag'), 'Tag', 'WordPress'); |
||
| 216 | $metadata->addKeyProperty($tagsEntityType, 'TagID', EdmPrimitiveType::INT32); |
||
| 217 | $metadata->addPrimitiveProperty($tagsEntityType, 'Name', EdmPrimitiveType::STRING); |
||
| 218 | $metadata->addPrimitiveProperty($tagsEntityType, 'Slug', EdmPrimitiveType::STRING); |
||
| 219 | $metadata->addPrimitiveProperty($tagsEntityType, 'Description', EdmPrimitiveType::STRING); |
||
| 220 | |||
| 221 | //Register the entity (resource) type 'Category' |
||
| 222 | $catsEntityType = $metadata->addEntityType(new ReflectionClass('Category'), 'Category', 'WordPress'); |
||
| 223 | $metadata->addKeyProperty($catsEntityType, 'CategoryID', EdmPrimitiveType::INT32); |
||
| 224 | $metadata->addPrimitiveProperty($catsEntityType, 'Name', EdmPrimitiveType::STRING); |
||
| 225 | $metadata->addPrimitiveProperty($catsEntityType, 'Slug', EdmPrimitiveType::STRING); |
||
| 226 | $metadata->addPrimitiveProperty($catsEntityType, 'Description', EdmPrimitiveType::STRING); |
||
| 227 | |||
| 228 | //Register the entity (resource) type 'Comment' |
||
| 229 | $commentsEntityType = $metadata->addEntityType(new ReflectionClass('Comment'), 'Comment', 'WordPress'); |
||
| 230 | $metadata->addKeyProperty($commentsEntityType, 'CommentID', EdmPrimitiveType::INT32); |
||
| 231 | $metadata->addPrimitiveProperty($commentsEntityType, 'PostID', EdmPrimitiveType::INT32); |
||
| 232 | $metadata->addPrimitiveProperty($commentsEntityType, 'Author', EdmPrimitiveType::STRING); |
||
| 233 | $metadata->addPrimitiveProperty($commentsEntityType, 'AuthorEmail', EdmPrimitiveType::STRING); |
||
| 234 | $metadata->addPrimitiveProperty($commentsEntityType, 'AuthorUrl', EdmPrimitiveType::STRING); |
||
| 235 | $metadata->addPrimitiveProperty($commentsEntityType, 'AuthorIp', EdmPrimitiveType::STRING); |
||
| 236 | $metadata->addETagProperty($commentsEntityType, 'Date', EdmPrimitiveType::DATETIME); |
||
| 237 | $metadata->addPrimitiveProperty($commentsEntityType, 'DateGmt', EdmPrimitiveType::DATETIME); |
||
| 238 | $metadata->addPrimitiveProperty($commentsEntityType, 'Content', EdmPrimitiveType::STRING); |
||
| 239 | $metadata->addPrimitiveProperty($commentsEntityType, 'Karma', EdmPrimitiveType::INT32); |
||
| 240 | $metadata->addPrimitiveProperty($commentsEntityType, 'Approved', EdmPrimitiveType::STRING); |
||
| 241 | $metadata->addPrimitiveProperty($commentsEntityType, 'Agent', EdmPrimitiveType::STRING); |
||
| 242 | $metadata->addPrimitiveProperty($commentsEntityType, 'Type', EdmPrimitiveType::STRING); |
||
| 243 | $metadata->addPrimitiveProperty($commentsEntityType, 'ParentID', EdmPrimitiveType::INT32); |
||
| 244 | $metadata->addPrimitiveProperty($commentsEntityType, 'UserID', EdmPrimitiveType::INT32); |
||
| 245 | |||
| 246 | //Register the entity (resource) type 'User' |
||
| 247 | $usersEntityType = $metadata->addEntityType(new ReflectionClass('User'), 'User', 'WordPress'); |
||
| 248 | $metadata->addKeyProperty($usersEntityType, 'UserID', EdmPrimitiveType::INT32); |
||
| 249 | $metadata->addPrimitiveProperty($usersEntityType, 'Login', EdmPrimitiveType::STRING); |
||
| 250 | $metadata->addPrimitiveProperty($usersEntityType, 'Nicename', EdmPrimitiveType::STRING); |
||
| 251 | $metadata->addPrimitiveProperty($usersEntityType, 'Email', EdmPrimitiveType::STRING); |
||
| 252 | $metadata->addPrimitiveProperty($usersEntityType, 'Url', EdmPrimitiveType::STRING); |
||
| 253 | $metadata->addETagProperty($usersEntityType, 'Registered', EdmPrimitiveType::DATETIME); |
||
| 254 | $metadata->addPrimitiveProperty($usersEntityType, 'Status', EdmPrimitiveType::INT16); |
||
| 255 | $metadata->addPrimitiveProperty($usersEntityType, 'DisplayName', EdmPrimitiveType::STRING); |
||
| 256 | |||
| 257 | $postsResourceSet = $metadata->addResourceSet('Posts', $postsEntityType); |
||
| 258 | $tagsResourceSet = $metadata->addResourceSet('Tags', $tagsEntityType); |
||
| 259 | $catsResourceSet = $metadata->addResourceSet('Categories', $catsEntityType); |
||
| 260 | $commentsResourceSet = $metadata->addResourceSet('Comments', $commentsEntityType); |
||
| 261 | $usersResourceSet = $metadata->addResourceSet('Users', $usersEntityType); |
||
| 262 | //associations of Post |
||
| 263 | $metadata->addResourceReferenceProperty($postsEntityType, 'User', $usersResourceSet); |
||
| 264 | $metadata->addResourceSetReferenceProperty($postsEntityType, 'Tags', $tagsResourceSet); |
||
| 265 | $metadata->addResourceSetReferenceProperty($postsEntityType, 'Categories', $catsResourceSet); |
||
| 266 | $metadata->addResourceSetReferenceProperty($postsEntityType, 'Comments', $commentsResourceSet); |
||
| 267 | //associations of Tag |
||
| 268 | $metadata->addResourceSetReferenceProperty($tagsEntityType, 'Posts', $postsResourceSet); |
||
| 269 | //associations of Category |
||
| 270 | $metadata->addResourceSetReferenceProperty($catsEntityType, 'Posts', $postsResourceSet); |
||
| 271 | //associations of Comment |
||
| 272 | $metadata->addResourceReferenceProperty($commentsEntityType, 'User', $usersResourceSet); |
||
| 273 | $metadata->addResourceReferenceProperty($commentsEntityType, 'Post', $postsResourceSet); |
||
| 274 | //associations of User |
||
| 275 | $metadata->addResourceSetReferenceProperty($usersEntityType, 'Posts', $postsResourceSet); |
||
| 276 | $metadata->addResourceSetReferenceProperty($usersEntityType, 'Comments', $commentsResourceSet); |
||
| 277 | |||
| 278 | return $metadata; |
||
| 279 | } |
||
| 367 |