| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| 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 |
||
| 20 | public function testParse() |
||
| 21 | { |
||
| 22 | $inputArray = [ |
||
| 23 | 'priority' => 0, |
||
| 24 | 'remoteId' => 'remote-id', |
||
| 25 | 'hidden' => 'true', |
||
| 26 | 'sortField' => 'PATH', |
||
| 27 | 'sortOrder' => 'ASC', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | $locationUpdate = $this->getParser(); |
||
| 31 | $result = $locationUpdate->parse($inputArray, $this->getParsingDispatcherMock()); |
||
| 32 | |||
| 33 | $this->assertInstanceOf( |
||
| 34 | RestLocationUpdateStruct::class, |
||
| 35 | $result, |
||
| 36 | 'LocationUpdateStruct not created correctly.' |
||
| 37 | ); |
||
| 38 | |||
| 39 | $this->assertInstanceOf( |
||
| 40 | LocationUpdateStruct::class, |
||
| 41 | $result->locationUpdateStruct, |
||
|
|
|||
| 42 | 'LocationUpdateStruct not created correctly.' |
||
| 43 | ); |
||
| 44 | |||
| 45 | $this->assertEquals( |
||
| 46 | 0, |
||
| 47 | $result->locationUpdateStruct->priority, |
||
| 48 | 'LocationUpdateStruct priority property not created correctly.' |
||
| 49 | ); |
||
| 50 | |||
| 51 | $this->assertEquals( |
||
| 52 | 'remote-id', |
||
| 53 | $result->locationUpdateStruct->remoteId, |
||
| 54 | 'LocationUpdateStruct remoteId property not created correctly.' |
||
| 55 | ); |
||
| 56 | |||
| 57 | $this->assertTrue( |
||
| 58 | $result->hidden, |
||
| 59 | 'hidden property not created correctly.' |
||
| 60 | ); |
||
| 61 | |||
| 62 | $this->assertEquals( |
||
| 63 | Location::SORT_FIELD_PATH, |
||
| 64 | $result->locationUpdateStruct->sortField, |
||
| 65 | 'LocationUpdateStruct sortField property not created correctly.' |
||
| 66 | ); |
||
| 67 | |||
| 68 | $this->assertEquals( |
||
| 69 | Location::SORT_ORDER_ASC, |
||
| 70 | $result->locationUpdateStruct->sortOrder, |
||
| 71 | 'LocationUpdateStruct sortOrder property not created correctly.' |
||
| 72 | ); |
||
| 73 | } |
||
| 74 | |||
| 164 |
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.