Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update MillisecondsToDateCast to specify return types for get and set…
… methods
  • Loading branch information
caleeli committed Jan 17, 2025
commit b7375b83ce52f9b718aa06aeee9fe747b1f9c482
18 changes: 14 additions & 4 deletions ProcessMaker/Casts/MillisecondsToDateCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@ class MillisecondsToDateCast implements CastsAttributes
/**
* Cast the given value.
*
* @param array<string, mixed> $attributes
* @param Model $model
* @param string $key
* @param mixed $value
* @param array<string, mixed> $attributes
*
* @return Carbon|null
*/
public function get(Model $model, string $key, mixed $value, array $attributes): mixed
public function get(Model $model, string $key, mixed $value, array $attributes): Carbon|null
{
return $value ? Carbon::createFromTimestampMs($value) : null;
}

/**
* Prepare the given value for storage.
*
* @param array<string, mixed> $attributes
* @param Model $model
* @param string $key
* @param mixed $value
* @param array<string, mixed> $attributes
*
* @return float|null
*/
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
public function set(Model $model, string $key, mixed $value, array $attributes): float|null
{
return $value ? Carbon::parse($value)->valueOf() : null;
}
Expand Down