| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 26 |
| 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 |
||
| 13 | public function testMatches() |
||
| 14 | { |
||
| 15 | $fixtureClass = 'UserDefinedForm_EmailRecipientCondition'; |
||
| 16 | //Test Blank |
||
| 17 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 18 | $blankObj = $this->objFromFixture($fixtureClass, 'blankTest'); |
||
| 19 | $this->assertTrue($blankObj->matches(array('Name' => null))); |
||
| 20 | $this->assertFalse($blankObj->matches(array('Name' => 'Jane'))); |
||
| 21 | |||
| 22 | //Test IsNotBlank |
||
| 23 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 24 | $blankObj = $this->objFromFixture($fixtureClass, 'isNotBlankTest'); |
||
| 25 | $this->assertTrue($blankObj->matches(array('Name' => 'Jane'))); |
||
| 26 | $this->assertFalse($blankObj->matches(array('Name' => null))); |
||
| 27 | |||
| 28 | //Test ValueLessthan |
||
| 29 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 30 | $blankObj = $this->objFromFixture($fixtureClass, 'valueLessThanTest'); |
||
| 31 | $this->assertTrue($blankObj->matches(array('Age' => 17))); |
||
| 32 | $this->assertFalse($blankObj->matches(array('Age' => 19))); |
||
| 33 | |||
| 34 | //Test ValueLessThanEquals |
||
| 35 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 36 | $blankObj = $this->objFromFixture($fixtureClass, 'valueLessThanEqualTest'); |
||
| 37 | $this->assertTrue($blankObj->matches(array('Age' => 18))); |
||
| 38 | $this->assertFalse($blankObj->matches(array('Age' => 19))); |
||
| 39 | |||
| 40 | //Test ValueGreaterThan |
||
| 41 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 42 | $blankObj = $this->objFromFixture($fixtureClass, 'valueGreaterThanTest'); |
||
| 43 | $this->assertTrue($blankObj->matches(array('Age' => 19))); |
||
| 44 | $this->assertFalse($blankObj->matches(array('Age' => 17))); |
||
| 45 | |||
| 46 | //Test ValueGreaterThanEquals |
||
| 47 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 48 | $blankObj = $this->objFromFixture($fixtureClass, 'valueGreaterThanEqualTest'); |
||
| 49 | $this->assertTrue($blankObj->matches(array('Age' => 18))); |
||
| 50 | $this->assertFalse($blankObj->matches(array('Age' => 17))); |
||
| 51 | |||
| 52 | //Test Equals |
||
| 53 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 54 | $blankObj = $this->objFromFixture($fixtureClass, 'equalsTest'); |
||
| 55 | $this->assertTrue($blankObj->matches(array('Age' => 18))); |
||
| 56 | $this->assertFalse($blankObj->matches(array('Age' => 17))); |
||
| 57 | |||
| 58 | //Test NotEquals |
||
| 59 | /** @var UserDefinedForm_EmailRecipientCondition $blankObj */ |
||
| 60 | $blankObj = $this->objFromFixture($fixtureClass, 'notEqualsTest'); |
||
| 61 | $this->assertTrue($blankObj->matches(array('Age' => 17))); |
||
| 62 | $this->assertFalse($blankObj->matches(array('Age' => 18))); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.