Conditions | 12 |
Paths | 22 |
Total Lines | 40 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
30 | public static function PrimitiveValueAsXml(IPrimitiveValue $v): string |
||
31 | { |
||
32 | if (method_exists($v, 'getValue')) { |
||
33 | EdmUtil::checkArgumentNull($v->getValue(), 'v->getValue'); |
||
34 | } |
||
35 | |||
36 | switch ($v->getValueKind()) { |
||
37 | case ValueKind::Boolean(): |
||
38 | assert($v instanceof IBooleanValue); |
||
39 | return self::BooleanAsXml($v->getValue()); |
||
40 | case ValueKind::Integer(): |
||
41 | assert($v instanceof IIntegerValue); |
||
42 | return self::LongAsXml($v->getValue()); |
||
43 | case ValueKind::Floating(): |
||
44 | assert($v instanceof IFloatingValue); |
||
45 | return self::FloatAsXml($v->getValue()); |
||
46 | case ValueKind::Guid(): |
||
47 | assert($v instanceof IGuidValue); |
||
48 | return self::GuidAsXml($v->getValue()); |
||
49 | case ValueKind::Binary(): |
||
50 | assert($v instanceof IBinaryValue); |
||
51 | return self::BinaryAsXml(/** @scrutinizer ignore-type */$v->getValue()); |
||
52 | case ValueKind::Decimal(): |
||
53 | assert($v instanceof IDecimalValue); |
||
54 | return self::DecimalAsXml($v->getValue()); |
||
55 | case ValueKind::String(): |
||
56 | assert($v instanceof IStringValue); |
||
57 | return self::StringAsXml(/** @scrutinizer ignore-type */$v->getValue()); |
||
58 | case ValueKind::DateTime(): |
||
59 | assert($v instanceof IDateTimeValue); |
||
60 | return self::DateTimeAsXml($v->getValue()); |
||
61 | case ValueKind::DateTimeOffset(): |
||
62 | assert($v instanceof IDateTimeOffsetValue); |
||
63 | return self::DateTimeOffsetAsXml($v->getValue()); |
||
64 | case ValueKind::Time(): |
||
65 | assert($v instanceof ITimeValue); |
||
66 | return self::TimeAsXml($v->getValue()); |
||
67 | default: |
||
68 | /* @noinspection PhpUnhandledExceptionInspection */ |
||
69 | throw new NotSupportedException(StringConst::ValueWriter_NonSerializableValue($v->getValueKind()->getKey())); |
||
70 | } |
||
137 |