| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 32 | public function testBuildFilter() |
||
| 33 | { |
||
| 34 | $astSubtree = new ASTGroup( |
||
| 35 | 'T_LOGIC_AND', |
||
| 36 | [ |
||
| 37 | new ASTGroup( |
||
| 38 | 'T_LOGIC_OR', |
||
| 39 | [ |
||
| 40 | new ASTAssertion( |
||
| 41 | 'test_dse_1', |
||
| 42 | 'T_OP_EQ', |
||
| 43 | 'value1' |
||
| 44 | ), |
||
| 45 | new ASTAssertion( |
||
| 46 | 'test_dse_2', |
||
| 47 | 'T_OP_LT', |
||
| 48 | 'value2' |
||
| 49 | ), |
||
| 50 | ] |
||
| 51 | ), |
||
| 52 | new ASTAssertion( |
||
| 53 | 'test_dse_3', |
||
| 54 | 'T_OP_NEQ', |
||
| 55 | 'value3' |
||
| 56 | ), |
||
| 57 | ] |
||
| 58 | ); |
||
| 59 | |||
| 60 | $filterDefinition1 = new Filter(); |
||
| 61 | $filterDefinition1->setConditionType('OR'); |
||
| 62 | $filter1 = new FilterCondition('test_dse_1', FilterCondition::METHOD_NUMERIC_EQ, 'value1', 'value1'); |
||
| 63 | $filter2 = new FilterCondition('test_dse_2', FilterCondition::METHOD_NUMERIC_LT, 'value2', 'value2'); |
||
| 64 | $filterDefinition1[] = $filter1; |
||
| 65 | $filterDefinition1[] = $filter2; |
||
| 66 | $filter3 = new FilterCondition('test_dse_3', FilterCondition::METHOD_NUMERIC_NEQ, 'value3', 'value3'); |
||
| 67 | $filterDefinition2 = new Filter(); |
||
| 68 | $filterDefinition2->setConditionType('AND'); |
||
| 69 | $filterDefinition2[] = $filterDefinition1; |
||
| 70 | $filterDefinition2[] = $filter3; |
||
| 71 | |||
| 72 | $expectedFilter = $filterDefinition2; |
||
| 73 | |||
| 74 | $dataSourceElements = [ |
||
| 75 | new Field('test_dse_1', '', '', new NumberDataType()), |
||
| 76 | new Field('test_dse_2', '', '', new NumberDataType()), |
||
| 77 | new Field('test_dse_3', '', '', new NumberDataType()), |
||
| 78 | ]; |
||
| 79 | |||
| 80 | $dataSourceProphecy = $this->prophesize(DataSourceInterface::class); |
||
| 81 | $dataSourceProphecy->getFields()->willReturn($dataSourceElements); |
||
| 82 | |||
| 83 | $interpreterFactory = new InterpreterFactory($this->extensionContainerProphecy->reveal(), new FilterConditionFactory(), $this->contextFactoryProphecy->reveal()); |
||
| 84 | $interpreter = $interpreterFactory->create($dataSourceProphecy->reveal()); |
||
| 85 | |||
| 86 | $actualFilter = $interpreter->buildFilter($astSubtree); |
||
| 87 | $this->assertEquals($expectedFilter, $actualFilter); |
||
| 88 | } |
||
| 89 | |||
| 119 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.