@@ -27,16 +27,16 @@ public static function new(Collection $days): self
27
27
public function __construct (Collection $ days )
28
28
{
29
29
$ this ->days = $ days
30
- ->sortBy (fn (SparkLineDay $ day ) => $ day ->day ->getTimestamp ())
31
- ->mapWithKeys (fn (SparkLineDay $ day ) => [$ day ->day ->format ('Y-m-d ' ) => $ day ]);
30
+ ->sortBy (fn (SparkLineDay $ day ) => $ day ->day ->getTimestamp ())
31
+ ->mapWithKeys (fn (SparkLineDay $ day ) => [$ day ->day ->format ('Y-m-d ' ) => $ day ]);
32
32
33
33
$ this ->maxValue = $ this ->resolveMaxValueFromDays ();
34
34
$ this ->maxItemAmount = $ this ->resolveMaxItemAmountFromDays ();
35
35
}
36
36
37
37
public function getTotal (): int
38
38
{
39
- return $ this ->days ->sum (fn (SparkLineDay $ day ) => $ day ->count ) ?? 0 ;
39
+ return $ this ->days ->sum (fn (SparkLineDay $ day ) => $ day ->count ) ?? 0 ;
40
40
}
41
41
42
42
public function getPeriod (): Period
@@ -138,7 +138,7 @@ private function resolveMaxValueFromDays(): int
138
138
}
139
139
140
140
return $ this ->days
141
- ->sortByDesc (fn (SparkLineDay $ day ) => $ day ->count )
141
+ ->sortByDesc (fn (SparkLineDay $ day ) => $ day ->count )
142
142
->first ()
143
143
->count ;
144
144
}
@@ -153,7 +153,7 @@ private function resolveCoordinates(): string
153
153
$ step = floor ($ this ->width / $ this ->maxItemAmount );
154
154
155
155
return collect (range (0 , $ this ->maxItemAmount ))
156
- ->map (fn (int $ days ) => (new DateTimeImmutable ("- {$ days } days " ))->format ('Y-m-d ' ))
156
+ ->map (fn (int $ days ) => (new DateTimeImmutable ("- {$ days } days " ))->format ('Y-m-d ' ))
157
157
->reverse ()
158
158
->mapWithKeys (function (string $ key ) {
159
159
/** @var SparkLineDay|null $day */
@@ -166,7 +166,7 @@ private function resolveCoordinates(): string
166
166
];
167
167
})
168
168
->values ()
169
- ->map (fn (int $ count , int $ index ) => $ index * $ step . ', ' . $ count )
169
+ ->map (fn (int $ count , int $ index ) => $ index * $ step . ', ' . $ count )
170
170
->implode (' ' );
171
171
}
172
172
}
0 commit comments