Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and actions-user committed Nov 30, 2021
1 parent f40f74e commit 78d9fdd
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ResultStores/StoredCheckResults/StoredCheckResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static function fromJson(string $json): StoredCheckResults
$properties = json_decode($json, true);

$checkResults = collect($properties['checkResults'])
->map(fn(array $lineProperties) => new StoredCheckResult(...$lineProperties))
->sortBy(fn(StoredCheckResult $result) => strtolower($result->label));
->map(fn (array $lineProperties) => new StoredCheckResult(...$lineProperties))
->sortBy(fn (StoredCheckResult $result) => strtolower($result->label));

return new self(
finishedAt: new DateTime($properties['finishedAt']),
Expand All @@ -35,8 +35,7 @@ public static function fromJson(string $json): StoredCheckResults
public function __construct(
DateTimeInterface $finishedAt = null,
?Collection $checkResults = null
)
{
) {
$this->finishedAt = $finishedAt ?? new DateTime();

$this->storedCheckResults = $checkResults ?? collect();
Expand All @@ -52,27 +51,27 @@ public function addCheck(StoredCheckResult $line): self
public function allChecksOk(): bool
{
return $this->storedCheckResults->contains(
fn(StoredCheckResult $line) => $line->status !== Status::ok()->value
fn (StoredCheckResult $line) => $line->status !== Status::ok()->value
);
}

public function containsFailingCheck(): bool
{
return !$this->allChecksOk();
return ! $this->allChecksOk();
}

public function containsCheckWithStatus(Status $status): bool
{
return $this->storedCheckResults->contains(
fn(StoredCheckResult $line) => $line->status === $status->value
fn (StoredCheckResult $line) => $line->status === $status->value
);
}

public function toJson(): string
{
return (string)json_encode([
'finishedAt' => $this->finishedAt->format('Y-m-d H:i:s'),
'checkResults' => $this->storedCheckResults->map(fn(StoredCheckResult $line) => $line->toArray()),
'checkResults' => $this->storedCheckResults->map(fn (StoredCheckResult $line) => $line->toArray()),
]);
}
}

0 comments on commit 78d9fdd

Please sign in to comment.