-
Notifications
You must be signed in to change notification settings - Fork 0
/
elvis-and-simple-if.cs
29 lines (23 loc) · 832 Bytes
/
elvis-and-simple-if.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
private IValues UpdateValue(IValues packages)
{
IValues wrappedPackages = packages;
if (wrappedPackages != null
&& wrappedPackages.packages != null
&& wrappedPackages.packages.Any()
&& wrappedPackages.packages[0].InnerValue != null
&& !wrappedPackages.packages[0].InnerValue.StartsWith("T"))
{
wrappedPackages.packages[0].InnerValue = unwrap(wrappedPackages.packages[0].InnerValue);
}
return wrappedPackages;
}
//Refactored
private IValues UpdateValue(IPackets packages)
{
var innerValue = packages?.packages?.FirstOrDefault()?.InnerValue;
if (innerValue == null || innerValue.StartsWith("T"))
return packages;
var wrappedPackages = packages.Clone();
wrappedPackages.packages[0].InnerValue = unwrap(innerValue);
return wrappedPackages;
}