Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 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 |
||
27 | public function testGetSet() |
||
28 | { |
||
29 | $this->assertEquals(0, $this->query->getStart()); |
||
30 | $this->query->setStart(1); |
||
31 | $this->assertEquals(1, $this->query->getStart()); |
||
32 | $this->assertEquals(10, $this->query->getRows()); |
||
33 | $this->query->setRows(20); |
||
34 | $this->assertEquals(20, $this->query->getRows()); |
||
35 | $this->assertEmpty($this->query->getClasses()); |
||
36 | $this->query->addClass('test'); |
||
37 | $this->assertCount(1, $this->query->getClasses()); |
||
38 | $this->query->setClasses([]); |
||
39 | $this->assertCount(0, $this->query->getClasses()); |
||
40 | $this->assertEmpty($this->query->getExclude()); |
||
41 | $this->query->setExclude(['test']); |
||
42 | $this->assertEquals(['test'], $this->query->getExclude()); |
||
43 | $this->query->addExclude('test', 'test'); |
||
44 | $this->assertEquals(['test', 'test' => 'test'], $this->query->getExclude()); |
||
45 | $this->query->addField('test'); |
||
46 | $this->assertEquals(['test'], $this->query->getFields()); |
||
47 | $this->assertEquals(0, $this->query->getFacetsMinCount()); |
||
48 | $this->query->setFacetsMinCount(15); |
||
49 | $this->assertEquals(15, $this->query->getFacetsMinCount()); |
||
50 | $this->query->setFields(['Field1', 'Field2']); |
||
51 | $this->assertCount(2, $this->query->getFields()); |
||
52 | $this->query->setSort(['Field1']); |
||
53 | $this->assertCount(1, $this->query->getSort()); |
||
54 | $this->query->setTerms(['Term' => 'Test']); |
||
55 | $this->assertCount(1, $this->query->getTerms()); |
||
56 | $this->query->addTerm('String', ['Field1'], 2); |
||
57 | $this->assertCount(2, $this->query->getTerms()); |
||
58 | $this->query->addFilter('Field1', 'test'); |
||
59 | $this->assertCount(1, $this->query->getFilter()); |
||
60 | $this->query->setFields([['Field1' => 'testing']]); |
||
61 | $this->assertCount(1, $this->query->getFilter()); |
||
62 | $this->query->setFilter([['Field1' => 'Test']]); |
||
63 | $this->assertCount(1, $this->query->getFilter()); |
||
64 | $this->query->setSpellcheck(false); |
||
65 | $this->assertFalse($this->query->hasSpellcheck()); |
||
66 | $this->query->addBoostedField('Field1', 2); |
||
67 | $this->assertEquals(2, $this->query->getBoostedFields()['Field1']); |
||
68 | $this->query->setBoostedFields(['Field' => 2]); |
||
69 | $this->assertEquals(2, $this->query->getBoostedFields()['Field']); |
||
70 | $this->query->setHighlight(['test']); |
||
71 | $this->assertEquals(['test'], $this->query->getHighlight()); |
||
72 | $this->query->addHighlight('test'); |
||
73 | $this->assertEquals(['test', 'test'], $this->query->getHighlight()); |
||
74 | $this->assertFalse($this->query->shouldFollowSpellcheck()); |
||
75 | $this->query->setFollowSpellcheck(true); |
||
76 | $this->assertTrue($this->query->shouldFollowSpellcheck()); |
||
77 | $this->query->addFacetFilter('Test', 'test'); |
||
78 | $this->assertEquals(['Test' => ['test']], $this->query->getFacetFilter()); |
||
79 | $this->query->setFacetFilter(['Testing' => [1, 2]]); |
||
80 | $this->assertEquals(['Testing' => [1, 2]], $this->query->getFacetFilter()); |
||
81 | } |
||
93 |