| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 43 |
| 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 |
||
| 54 | public function testMoveSubtree() |
||
| 55 | { |
||
| 56 | $repository = $this->getRepository(); |
||
| 57 | $locationService = $repository->getLocationService(); |
||
| 58 | $contentService = $repository->getContentService(); |
||
| 59 | $searchService = $repository->getSearchService(); |
||
| 60 | |||
| 61 | $rootLocationId = 2; |
||
| 62 | $membersContentId = 11; |
||
| 63 | $adminsContentId = 12; |
||
| 64 | $editorsContentId = 13; |
||
| 65 | $membersContentInfo = $contentService->loadContentInfo($membersContentId); |
||
| 66 | $adminsContentInfo = $contentService->loadContentInfo($adminsContentId); |
||
| 67 | $editorsContentInfo = $contentService->loadContentInfo($editorsContentId); |
||
| 68 | |||
| 69 | $locationCreateStruct = $locationService->newLocationCreateStruct($rootLocationId); |
||
| 70 | $membersLocation = $locationService->createLocation($membersContentInfo, $locationCreateStruct); |
||
| 71 | $editorsLocation = $locationService->createLocation($editorsContentInfo, $locationCreateStruct); |
||
| 72 | $adminsLocation = $locationService->createLocation( |
||
| 73 | $adminsContentInfo, |
||
| 74 | $locationService->newLocationCreateStruct($membersLocation->id) |
||
| 75 | ); |
||
| 76 | |||
| 77 | $this->refreshSearch($repository); |
||
| 78 | |||
| 79 | // Not found under Editors |
||
| 80 | $criterion = new Criterion\ParentLocationId($editorsLocation->id); |
||
| 81 | $query = new LocationQuery(array('filter' => $criterion)); |
||
| 82 | $result = $searchService->findLocations($query); |
||
| 83 | $this->assertEquals(0, $result->totalCount); |
||
| 84 | |||
| 85 | // Found under Members |
||
| 86 | $criterion = new Criterion\ParentLocationId($membersLocation->id); |
||
| 87 | $query = new LocationQuery(array('filter' => $criterion)); |
||
| 88 | $result = $searchService->findLocations($query); |
||
| 89 | $this->assertEquals(1, $result->totalCount); |
||
| 90 | $this->assertEquals( |
||
| 91 | $adminsLocation->id, |
||
| 92 | $result->searchHits[0]->valueObject->id |
||
| 93 | ); |
||
| 94 | |||
| 95 | $locationService->moveSubtree($adminsLocation, $editorsLocation); |
||
| 96 | $this->refreshSearch($repository); |
||
| 97 | |||
| 98 | // Found under Editors |
||
| 99 | $criterion = new Criterion\ParentLocationId($editorsLocation->id); |
||
| 100 | $query = new LocationQuery(array('filter' => $criterion)); |
||
| 101 | $result = $searchService->findLocations($query); |
||
| 102 | $this->assertEquals(1, $result->totalCount); |
||
| 103 | $this->assertEquals( |
||
| 104 | $adminsLocation->id, |
||
| 105 | $result->searchHits[0]->valueObject->id |
||
| 106 | ); |
||
| 107 | |||
| 108 | // Not found under Members |
||
| 109 | $criterion = new Criterion\ParentLocationId($membersLocation->id); |
||
| 110 | $query = new LocationQuery(array('filter' => $criterion)); |
||
| 111 | $result = $searchService->findLocations($query); |
||
| 112 | $this->assertEquals(0, $result->totalCount); |
||
| 113 | } |
||
| 114 | |||
| 206 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.