| Conditions | 1 |
| Paths | 1 |
| Total Lines | 106 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 68 | public function predefinedSchemaProvider() |
||
| 69 | { |
||
| 70 | return [ |
||
| 71 | [ |
||
| 72 | '{ |
||
| 73 | __schema { |
||
| 74 | types { |
||
| 75 | name, |
||
| 76 | fields { |
||
| 77 | name |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 | }', |
||
| 82 | [ |
||
| 83 | 'data' => [ |
||
| 84 | '__schema' => [ |
||
| 85 | 'types' => [ |
||
| 86 | ['name' => 'latest', 'fields' => [['name' => 'id'], ['name' => 'name']]], |
||
| 87 | ['name' => 'Int', 'fields' => []], |
||
| 88 | ['name' => 'String', 'fields' => []], |
||
| 89 | ['name' => '__Schema', 'fields' => [['name' => 'queryType'], ['name' => 'mutationType'], ['name' => 'types']]], |
||
| 90 | ['name' => '__Type', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]], |
||
| 91 | ['name' => '__TypeList', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]], |
||
| 92 | ['name' => '__InputValuesList', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'type'], ['name' => 'defaultValue']]], |
||
| 93 | ['name' => '__EnumValueList', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'deprecationReason'], ['name' => 'isDeprecated']]], |
||
| 94 | ['name' => 'Boolean', 'fields' => []], |
||
| 95 | ['name' => '__FieldList', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'isDeprecated'], ['name' => 'deprecationReason'], ['name' => 'type'], ['name' => 'args']]], |
||
| 96 | ['name' => '__ArgumentList', 'fields' => [['name' => 'name'], ['name' => 'description']]], |
||
| 97 | ['name' => '__InterfaceList', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]], |
||
| 98 | ['name' => '__PossibleOfList', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]], |
||
| 99 | ] |
||
| 100 | ] |
||
| 101 | ] |
||
| 102 | ] |
||
| 103 | ], |
||
| 104 | [ |
||
| 105 | '{ |
||
| 106 | test : __schema { |
||
| 107 | queryType { |
||
| 108 | kind, |
||
| 109 | name, |
||
| 110 | fields { |
||
| 111 | name, |
||
| 112 | isDeprecated, |
||
| 113 | deprecationReason, |
||
| 114 | description, |
||
| 115 | type { |
||
| 116 | name |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 | } |
||
| 121 | }', |
||
| 122 | ['data' => [ |
||
| 123 | 'test' => [ |
||
| 124 | 'queryType' => [ |
||
| 125 | 'name' => 'TestSchema', |
||
| 126 | 'kind' => 'OBJECT', |
||
| 127 | 'fields' => [ |
||
| 128 | ['name' => 'latest', 'isDeprecated' => true, 'deprecationReason' => 'for test', 'description' => 'for test', 'type' => ['name' => 'latest']], |
||
| 129 | ['name' => '__schema', 'isDeprecated' => false, 'deprecationReason' => '', 'description' => '', 'type' => ['name' => '__Schema']], |
||
| 130 | ['name' => '__type', 'isDeprecated' => false, 'deprecationReason' => '', 'description' => '', 'type' => ['name' => '__Type']] |
||
| 131 | ] |
||
| 132 | ] |
||
| 133 | ] |
||
| 134 | ]] |
||
| 135 | ], |
||
| 136 | [ |
||
| 137 | '{ |
||
| 138 | __schema { |
||
| 139 | queryType { |
||
| 140 | kind, |
||
| 141 | name, |
||
| 142 | description, |
||
| 143 | interfaces { |
||
| 144 | name |
||
| 145 | }, |
||
| 146 | possibleTypes { |
||
| 147 | name |
||
| 148 | }, |
||
| 149 | inputFields { |
||
| 150 | name |
||
| 151 | }, |
||
| 152 | ofType{ |
||
| 153 | name |
||
| 154 | } |
||
| 155 | } |
||
| 156 | } |
||
| 157 | }', |
||
| 158 | ['data' => [ |
||
| 159 | '__schema' => [ |
||
| 160 | 'queryType' => [ |
||
| 161 | 'kind' => 'OBJECT', |
||
| 162 | 'name' => 'TestSchema', |
||
| 163 | 'description' => 'Root of TestSchema', |
||
| 164 | 'interfaces' => [], |
||
| 165 | 'possibleTypes' => [], |
||
| 166 | 'inputFields' => [], |
||
| 167 | 'ofType' => [] |
||
| 168 | ] |
||
| 169 | ] |
||
| 170 | ]] |
||
| 171 | ] |
||
| 172 | ]; |
||
| 173 | } |
||
| 174 | |||
| 231 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.