Conditions | 28 |
Paths | 28 |
Total Lines | 114 |
Code Lines | 111 |
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 |
||
53 | public function visitExpression(IExpression $expression): void |
||
54 | { |
||
55 | /** @var EdmModelVisitor $this */ |
||
56 | switch ($expression->getExpressionKind()) { |
||
57 | case ExpressionKind::AssertType(): |
||
58 | assert($expression instanceof IAssertTypeExpression); |
||
59 | $this->processAssertTypeExpression($expression); |
||
60 | break; |
||
61 | case ExpressionKind::BinaryConstant(): |
||
62 | assert($expression instanceof IBinaryConstantExpression); |
||
63 | $this->processBinaryConstantExpression($expression); |
||
64 | break; |
||
65 | case ExpressionKind::BooleanConstant(): |
||
66 | assert($expression instanceof IBooleanConstantExpression); |
||
67 | $this->processBooleanConstantExpression($expression); |
||
68 | break; |
||
69 | case ExpressionKind::Collection(): |
||
70 | assert($expression instanceof ICollectionExpression); |
||
71 | $this->processCollectionExpression($expression); |
||
72 | break; |
||
73 | case ExpressionKind::DateTimeConstant(): |
||
74 | assert($expression instanceof IDateTimeConstantExpression); |
||
75 | $this->processDateTimeConstantExpression($expression); |
||
76 | break; |
||
77 | case ExpressionKind::DateTimeOffsetConstant(): |
||
78 | assert($expression instanceof IDateTimeOffsetConstantExpression); |
||
79 | $this->processDateTimeOffsetConstantExpression($expression); |
||
80 | break; |
||
81 | case ExpressionKind::DecimalConstant(): |
||
82 | assert($expression instanceof IDecimalConstantExpression); |
||
83 | $this->processDecimalConstantExpression($expression); |
||
84 | break; |
||
85 | case ExpressionKind::EntitySetReference(): |
||
86 | assert($expression instanceof IEntitySetReferenceExpression); |
||
87 | $this->processEntitySetReferenceExpression($expression); |
||
88 | break; |
||
89 | case ExpressionKind::EnumMemberReference(): |
||
90 | assert($expression instanceof IEnumMemberReferenceExpression); |
||
91 | $this->processEnumMemberReferenceExpression($expression); |
||
92 | break; |
||
93 | case ExpressionKind::FloatingConstant(): |
||
94 | assert($expression instanceof IFloatingConstantExpression); |
||
95 | $this->processFloatingConstantExpression($expression); |
||
96 | break; |
||
97 | case ExpressionKind::FunctionApplication(): |
||
98 | assert($expression instanceof IApplyExpression); |
||
99 | $this->processFunctionApplicationExpression($expression); |
||
100 | break; |
||
101 | case ExpressionKind::FunctionReference(): |
||
102 | assert($expression instanceof IFunctionReferenceExpression); |
||
103 | $this->processFunctionReferenceExpression($expression); |
||
104 | break; |
||
105 | case ExpressionKind::GuidConstant(): |
||
106 | assert($expression instanceof IGuidConstantExpression); |
||
107 | $this->processGuidConstantExpression($expression); |
||
108 | break; |
||
109 | case ExpressionKind::If(): |
||
110 | assert($expression instanceof IIfExpression); |
||
111 | $this->processIfExpression($expression); |
||
112 | break; |
||
113 | case ExpressionKind::IntegerConstant(): |
||
114 | assert($expression instanceof IIntegerConstantExpression); |
||
115 | $this->processIntegerConstantExpression($expression); |
||
116 | break; |
||
117 | case ExpressionKind::IsType(): |
||
118 | assert($expression instanceof IIsTypeExpression); |
||
119 | $this->processIsTypeExpression($expression); |
||
120 | break; |
||
121 | case ExpressionKind::ParameterReference(): |
||
122 | assert($expression instanceof IParameterReferenceExpression); |
||
123 | $this->processParameterReferenceExpression($expression); |
||
124 | break; |
||
125 | case ExpressionKind::LabeledExpressionReference(): |
||
126 | assert($expression instanceof ILabeledExpressionReferenceExpression); |
||
127 | $this->processLabeledExpressionReferenceExpression($expression); |
||
128 | break; |
||
129 | case ExpressionKind::Labeled(): |
||
130 | assert($expression instanceof ILabeledExpression); |
||
131 | $this->processLabeledExpression($expression); |
||
132 | break; |
||
133 | case ExpressionKind::Null(): |
||
134 | assert($expression instanceof INullExpression); |
||
135 | $this->processNullConstantExpression($expression); |
||
136 | break; |
||
137 | case ExpressionKind::Path(): |
||
138 | assert($expression instanceof IPathExpression); |
||
139 | $this->processPathExpression($expression); |
||
140 | break; |
||
141 | case ExpressionKind::PropertyReference(): |
||
142 | assert($expression instanceof IPropertyReferenceExpression); |
||
143 | $this->processPropertyReferenceExpression($expression); |
||
144 | break; |
||
145 | case ExpressionKind::Record(): |
||
146 | assert($expression instanceof IRecordExpression); |
||
147 | $this->processRecordExpression($expression); |
||
148 | break; |
||
149 | case ExpressionKind::StringConstant(): |
||
150 | assert($expression instanceof IStringConstantExpression); |
||
151 | $this->processStringConstantExpression($expression); |
||
152 | break; |
||
153 | case ExpressionKind::TimeConstant(): |
||
154 | assert($expression instanceof ITimeConstantExpression); |
||
155 | $this->processTimeConstantExpression($expression); |
||
156 | break; |
||
157 | case ExpressionKind::ValueTermReference(): |
||
158 | assert($expression instanceof IPropertyReferenceExpression); |
||
159 | $this->processPropertyReferenceExpression($expression); |
||
160 | break; |
||
161 | case ExpressionKind::None(): |
||
162 | $this->processExpression($expression); |
||
163 | break; |
||
164 | default: |
||
165 | throw new InvalidOperationException( |
||
166 | StringConst::UnknownEnumVal_TermKind($expression->getExpressionKind()->getKey()) |
||
167 | ); |
||
179 |