Conditions | 1 |
Paths | 1 |
Total Lines | 128 |
Code Lines | 92 |
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 |
||
25 | public function it_builds_mapping_with_fluent_syntax() |
||
26 | { |
||
27 | $this->blueprint->text('TEXT') |
||
28 | ->analyzer('ANALYZER') |
||
29 | ->boost(5); |
||
30 | |||
31 | $this->blueprint->keyword('KEYWORD'); |
||
32 | $this->blueprint->long('LONG'); |
||
33 | $this->blueprint->integer('INTEGER'); |
||
34 | $this->blueprint->short('SHORT'); |
||
35 | $this->blueprint->byte('BYTE'); |
||
36 | $this->blueprint->double('DOUBLE'); |
||
37 | $this->blueprint->float('FLOAT'); |
||
38 | $this->blueprint->halfFloat('HALF_FLOAT'); |
||
39 | $this->blueprint->scaledFloat('SCALED_FLOAT'); |
||
40 | $this->blueprint->date('DATE'); |
||
41 | $this->blueprint->boolean('BOOLEAN'); |
||
42 | $this->blueprint->binary('BINARY'); |
||
43 | $this->blueprint->range('RANGE_INTEGER', 'integer'); |
||
44 | $this->blueprint->range('RANGE_FLOAT', 'float'); |
||
45 | $this->blueprint->range('RANGE_LONG', 'long'); |
||
46 | $this->blueprint->range('RANGE_DOUBLE', 'double'); |
||
47 | $this->blueprint->range('RANGE_DATE', 'date'); |
||
48 | $this->blueprint->range('RANGE_IP', 'ip'); |
||
49 | $this->blueprint->nested('NESTED')->callback(function (Blueprint $blueprint) { |
||
50 | $blueprint->keyword('NESTED_KEYWORD'); |
||
51 | }); |
||
52 | $this->blueprint->object('OBJECT')->callback(function (Blueprint $blueprint) { |
||
53 | $blueprint->keyword('OBJECT_KEYWORD'); |
||
54 | }); |
||
55 | $this->blueprint->geoPoint('GEO_POINT'); |
||
56 | $this->blueprint->geoShape('GEO_SHAPE'); |
||
57 | $this->blueprint->ip('IP'); |
||
58 | $this->blueprint->completion('COMPLETION'); |
||
59 | $this->blueprint->tokenCount('TOKEN_COUNT'); |
||
60 | |||
61 | $this->assertEquals([ |
||
62 | 'TEXT' => [ |
||
63 | 'type' => 'text', |
||
64 | 'analyzer' => 'ANALYZER', |
||
65 | 'boost' => 5 |
||
66 | ], |
||
67 | 'KEYWORD' => [ |
||
68 | 'type' => 'keyword' |
||
69 | ], |
||
70 | 'LONG' => [ |
||
71 | 'type' => 'long' |
||
72 | ], |
||
73 | 'INTEGER' => [ |
||
74 | 'type' => 'integer' |
||
75 | ], |
||
76 | 'SHORT' => [ |
||
77 | 'type' => 'short' |
||
78 | ], |
||
79 | 'BYTE' => [ |
||
80 | 'type' => 'byte' |
||
81 | ], |
||
82 | 'DOUBLE' => [ |
||
83 | 'type' => 'double' |
||
84 | ], |
||
85 | 'FLOAT' => [ |
||
86 | 'type' => 'float' |
||
87 | ], |
||
88 | 'HALF_FLOAT' => [ |
||
89 | 'type' => 'half_float' |
||
90 | ], |
||
91 | 'SCALED_FLOAT' => [ |
||
92 | 'type' => 'scaled_float' |
||
93 | ], |
||
94 | 'DATE' => [ |
||
95 | 'type' => 'date' |
||
96 | ], |
||
97 | 'BOOLEAN' => [ |
||
98 | 'type' => 'boolean' |
||
99 | ], |
||
100 | 'BINARY' => [ |
||
101 | 'type' => 'binary' |
||
102 | ], |
||
103 | 'RANGE_INTEGER' => [ |
||
104 | 'type' => 'integer_range' |
||
105 | ], |
||
106 | 'RANGE_FLOAT' => [ |
||
107 | 'type' => 'float_range' |
||
108 | ], |
||
109 | 'RANGE_LONG' => [ |
||
110 | 'type' => 'long_range' |
||
111 | ], |
||
112 | 'RANGE_DOUBLE' => [ |
||
113 | 'type' => 'double_range' |
||
114 | ], |
||
115 | 'RANGE_DATE' => [ |
||
116 | 'type' => 'date_range' |
||
117 | ], |
||
118 | 'RANGE_IP' => [ |
||
119 | 'type' => 'ip_range' |
||
120 | ], |
||
121 | 'NESTED' => [ |
||
122 | 'type' => 'nested', |
||
123 | 'properties' => [ |
||
124 | 'NESTED_KEYWORD' => [ |
||
125 | 'type' => 'keyword' |
||
126 | ] |
||
127 | ] |
||
128 | ], |
||
129 | 'OBJECT' => [ |
||
130 | 'type' => 'nested', |
||
131 | 'properties' => [ |
||
132 | 'OBJECT_KEYWORD' => [ |
||
133 | 'type' => 'keyword' |
||
134 | ] |
||
135 | ] |
||
136 | ], |
||
137 | 'GEO_POINT' => [ |
||
138 | 'type' => 'geo_point' |
||
139 | ], |
||
140 | 'GEO_SHAPE' => [ |
||
141 | 'type' => 'geo_shape' |
||
142 | ], |
||
143 | 'IP' => [ |
||
144 | 'type' => 'ip' |
||
145 | ], |
||
146 | 'COMPLETION' => [ |
||
147 | 'type' => 'completion' |
||
148 | ], |
||
149 | 'TOKEN_COUNT' => [ |
||
150 | 'type' => 'token_count' |
||
151 | ] |
||
152 | ], $this->blueprint->toDsl()); |
||
153 | } |
||
179 |