| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 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 |
||
| 60 | public function testGetValueHash() { |
||
| 61 | $list = new HashableObjectStorage(); |
||
| 62 | $originalList = clone $list; |
||
| 63 | |||
| 64 | $hash = $list->getValueHash(); |
||
| 65 | $this->assertInternalType( 'string', $hash ); |
||
| 66 | |||
| 67 | $one = new HashableObject( 1 ); |
||
| 68 | $two = new HashableObject( 1 ); |
||
| 69 | |||
| 70 | $list->attach( $one ); |
||
| 71 | $list->attach( $two ); |
||
| 72 | |||
| 73 | $newHash = $list->getValueHash(); |
||
| 74 | |||
| 75 | $this->assertNotEquals( |
||
| 76 | $hash, |
||
| 77 | $newHash, |
||
| 78 | 'The hash of HashableObjectStorage with different content should be different' |
||
| 79 | ); |
||
| 80 | |||
| 81 | $this->assertFalse( $list->equals( $originalList ) ); |
||
| 82 | |||
| 83 | $originalList = clone $list; |
||
| 84 | |||
| 85 | $list->detach( $one ); |
||
| 86 | $list->detach( $two ); |
||
| 87 | |||
| 88 | $list->attach( $two ); |
||
| 89 | $list->attach( $one ); |
||
| 90 | |||
| 91 | $this->assertEquals( |
||
| 92 | $newHash, |
||
| 93 | $list->getValueHash(), |
||
| 94 | 'The hash of HashableObjectStorage with the same elements in different order should be the same' |
||
| 95 | ); |
||
| 96 | |||
| 97 | $this->assertTrue( $list->equals( $originalList ) ); |
||
| 98 | |||
| 99 | $list->detach( $one ); |
||
| 100 | $list->detach( $two ); |
||
| 101 | |||
| 102 | $list->attach( new HashableObject( 1 ) ); |
||
| 103 | $list->attach( new HashableObject( 1 ) ); |
||
| 104 | |||
| 105 | $this->assertEquals( |
||
| 106 | $newHash, |
||
| 107 | $list->getValueHash(), |
||
| 108 | 'The hash of HashableObjectStorage with different instances of the same elemnets should be the same' |
||
| 109 | ); |
||
| 110 | |||
| 111 | $this->assertTrue( $list->equals( $originalList ) ); |
||
| 112 | } |
||
| 113 | |||
| 133 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.