| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| Code Lines | 38 |
| 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 |
||
| 34 | public function testGivenThatTheConfigurationTreeForTheBundleIsBuiltThenAllOfItsOptionsAreInPlace() |
||
| 35 | { |
||
| 36 | /** @var ArrayNode $compiledTree */ |
||
| 37 | $compiledTree = (new Configuration())->getConfigTreeBuilder()->buildTree(); |
||
| 38 | |||
| 39 | $this->assertTrue($compiledTree instanceof ArrayNode); |
||
| 40 | $children = $compiledTree->getChildren(); |
||
| 41 | |||
| 42 | $this->assertArrayHasKey('project_id', $children); |
||
| 43 | /** @var ScalarNode $projectIdNode */ |
||
| 44 | $projectIdNode = $children['project_id']; |
||
| 45 | $this->assertEquals(AirbrakeDefaultEnum::PROJECT_KEY, $projectIdNode->getDefaultValue()); |
||
| 46 | |||
| 47 | $this->assertArrayHasKey('project_key', $children); |
||
| 48 | /** @var ScalarNode $projectKeyNode */ |
||
| 49 | $projectKeyNode = $children['project_key']; |
||
| 50 | $this->assertEquals(AirbrakeDefaultEnum::PROJECT_KEY, $projectKeyNode->getDefaultValue()); |
||
| 51 | |||
| 52 | $this->assertArrayHasKey('host', $children); |
||
| 53 | /** @var ScalarNode $hostNode */ |
||
| 54 | $hostNode = $children['host']; |
||
| 55 | $this->assertEquals(AirbrakeDefaultEnum::HOST, $hostNode->getDefaultValue()); |
||
| 56 | |||
| 57 | $this->assertArrayHasKey('ignored_exceptions', $children); |
||
| 58 | /** @var ArrayNode $ignoredExceptionsNode */ |
||
| 59 | $ignoredExceptionsNode = $children['ignored_exceptions']; |
||
| 60 | $this->assertInternalType('array', $ignoredExceptionsNode->getDefaultValue()); |
||
| 61 | $this->assertEquals(AirbrakeDefaultEnum::IGNORED_EXCEPTIONS, $ignoredExceptionsNode->getDefaultValue()); |
||
| 62 | |||
| 63 | $this->assertArrayHasKey('global_exception_instance', $children); |
||
| 64 | /** @var BooleanNode $globalExceptionInstanceNode */ |
||
| 65 | $globalExceptionInstanceNode = $children['global_exception_instance']; |
||
| 66 | $this->assertEquals(AirbrakeDefaultEnum::GLOBAL_EXCEPTION_INSTANCE, $globalExceptionInstanceNode->getDefaultValue()); |
||
| 67 | |||
| 68 | $this->assertArrayHasKey('global_error_and_exception_handler', $children); |
||
| 69 | /** @var BooleanNode $globalErrorAndExceptionHandlerNode */ |
||
| 70 | $globalErrorAndExceptionHandlerNode = $children['global_error_and_exception_handler']; |
||
| 71 | $this->assertEquals(AirbrakeDefaultEnum::GLOBAL_ERROR_AND_EXCEPTION_HANDLER, $globalErrorAndExceptionHandlerNode->getDefaultValue()); |
||
| 72 | |||
| 73 | $this->assertArrayHasKey('http_client', $children); |
||
| 74 | /** @var ScalarNode $httpClientNode */ |
||
| 75 | $httpClientNode = $children['http_client']; |
||
| 76 | $this->assertEquals(AirbrakeDefaultEnum::HTTP_CLIENT, $httpClientNode->getDefaultValue()); |
||
| 77 | |||
| 78 | $this->assertArrayHasKey('root_directory', $children); |
||
| 79 | /** @var ScalarNode $rootDirectoryNode */ |
||
| 80 | $rootDirectoryNode = $children['root_directory']; |
||
| 81 | $this->assertEquals(AirbrakeDefaultEnum::ROOT_DIRECTORY, $rootDirectoryNode->getDefaultValue()); |
||
| 82 | |||
| 83 | $this->assertArrayHasKey('environment', $children); |
||
| 84 | /** @var ScalarNode $environmentNode */ |
||
| 85 | $environmentNode = $children['environment']; |
||
| 86 | $this->assertEquals(AirbrakeDefaultEnum::ENVIRONMENT, $environmentNode->getDefaultValue()); |
||
| 87 | |||
| 88 | $this->assertArrayHasKey('app_version', $children); |
||
| 89 | /** @var ScalarNode $appVersionNode */ |
||
| 90 | $appVersionNode = $children['app_version']; |
||
| 91 | $this->assertEquals(AirbrakeDefaultEnum::APP_VERSION, $appVersionNode->getDefaultValue()); |
||
| 92 | |||
| 93 | $this->assertArrayHasKey('listener_enabled', $children); |
||
| 94 | /** @var ScalarNode $listenerEnabledNode */ |
||
| 95 | $listenerEnabledNode = $children['listener_enabled']; |
||
| 96 | $this->assertEquals(AirbrakeDefaultEnum::LISTNER_ENABLED, $listenerEnabledNode->getDefaultValue()); |
||
| 97 | } |
||
| 98 | } |
||
| 99 |